Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Fix angular.element.cache memory leak #1365

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/uiSelectChoicesDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ uis.directive('uiSelectChoices',

$compile(element, transcludeFn)(scope); //Passing current transcludeFn to be able to append elements correctly from uisTranscludeAppend

scope.$on('$destroy', function() {
choices.remove();
});

scope.$watch('$select.search', function(newValue) {
if(newValue && !$select.open && $select.multiple) $select.activate(false, true);
$select.activeIndex = $select.tagging.isActivated ? -1 : 0;
Expand Down
7 changes: 7 additions & 0 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ describe('ui-select tests', function() {

});

it('should not leak memory', function() {
var cacheLenght = Object.keys(angular.element.cache).length;
createUiSelect().remove();
scope.$destroy();
expect(Object.keys(angular.element.cache).length).toBe(cacheLenght);
});

it('should compile child directives', function() {
var el = createUiSelect();

Expand Down