From 89303fd2dccb780bea594b16b8ec85d9f3bd8f92 Mon Sep 17 00:00:00 2001 From: danilsomsikov Date: Fri, 11 Jan 2013 18:21:13 +0100 Subject: fix(ngSwitch): don't leak when destroyed while not attached The leak can occur when ngSwich is used inside ngRepeat or any other directive which is destroyed while its transcluded content (which includes ngSwitch) is not attached to the DOM. Refactor ngSwitch to use controller instead of storing data on compile node. This means that we don't need to clean up the jq data cache. Controller reference is released when the linking fn is released. Closes #1621 --- test/ng/directive/ngSwitchSpec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/ng/directive') diff --git a/test/ng/directive/ngSwitchSpec.js b/test/ng/directive/ngSwitchSpec.js index 66ae5562..ee91f79d 100644 --- a/test/ng/directive/ngSwitchSpec.js +++ b/test/ng/directive/ngSwitchSpec.js @@ -90,4 +90,19 @@ describe('ngSwitch', function() { expect(child2).toBeDefined(); expect(child2).not.toBe(child1); })); + + + it('should not leak jq data when compiled but not attached to parent when parent is destroyed', + inject(function($rootScope, $compile) { + element = $compile( + '