Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(menu): fix memory leak on component destroy
Browse files Browse the repository at this point in the history
Closes #3775.
  • Loading branch information
isyun authored and ThomasBurleson committed Jul 16, 2015
1 parent 2132cd2 commit 1a9a530
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/menu/_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,8 @@ function MenuDirective($mdMenu) {
mdMenuCtrl.init(menuContainer);

scope.$on('$destroy', function() {
if (mdMenuCtrl.isOpen) {
menuContainer.remove();
mdMenuCtrl.close();
}
menuContainer.remove();
mdMenuCtrl.close();
});

}
Expand Down Expand Up @@ -207,6 +205,8 @@ function MenuController($mdMenu, $attrs, $element, $scope) {

// Use the $mdMenu interim element service to close the menu contents
this.close = function closeMenu(skipFocus) {
if ( !ctrl.isOpen ) return;

ctrl.isOpen = false;
triggerElement.setAttribute('aria-expanded', 'false');
$mdMenu.hide();
Expand Down

0 comments on commit 1a9a530

Please sign in to comment.