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

Commit cf5442e

Browse files
author
Teemu Kokkonen
committed
Fix angular.element.cache memory leak
1 parent 4467b82 commit cf5442e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/uiSelectChoicesDirective.js

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ uis.directive('uiSelectChoices',
5151

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

54+
scope.$on('$destroy', function() {
55+
choices.remove();
56+
});
57+
5458
scope.$watch('$select.search', function(newValue) {
5559
if(newValue && !$select.open && $select.multiple) $select.activate(false, true);
5660
$select.activeIndex = $select.tagging.isActivated ? -1 : 0;

test/select.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ describe('ui-select tests', function() {
313313

314314
});
315315

316+
it('should not leak memory', function() {
317+
var cacheLenght = Object.keys(angular.element.cache).length;
318+
createUiSelect().remove();
319+
scope.$destroy();
320+
expect(Object.keys(angular.element.cache).length).toBe(cacheLenght);
321+
});
322+
316323
it('should compile child directives', function() {
317324
var el = createUiSelect();
318325

0 commit comments

Comments
 (0)