Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(typeahead): release references on destruction
Browse files Browse the repository at this point in the history
- Release reference to manually managed scopes, which prevent proper garbage collection

Closes #4299
Fixes #4298
  • Loading branch information
yoann-antoviaque authored and wesleycho committed Aug 28, 2015
1 parent 1bba8b4 commit 695db9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/dropdown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,10 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
}
});

$scope.$on('$destroy', function() {
var offDestroy = $scope.$on('$destroy', function() {
scope.$destroy();
});
scope.$on('$destroy', offDestroy);
}])

.directive('dropdown', function() {
Expand Down
5 changes: 3 additions & 2 deletions src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
//create a child scope for the typeahead directive so we are not polluting original scope
//with typeahead-specific data (matches, query etc.)
var scope = originalScope.$new();
originalScope.$on('$destroy', function() {
scope.$destroy();
var offDestroy = originalScope.$on('$destroy', function(){
scope.$destroy();
});
scope.$on('$destroy', offDestroy);

// WAI-ARIA
var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);
Expand Down

0 comments on commit 695db9d

Please sign in to comment.