From 1f23cfe9c751f84d9fc996df6d54961b2e46e868 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Mon, 18 Feb 2013 12:05:16 +0000 Subject: fix(compile): should not leak memory when there are top level empty text nodes The change to prevent elements being wrapped around empty text nodes caused these empty text nodes to have scopes and controllers attached, through jqLite.data() calls, which led to memory leaks and errors in IE8. Now we exclude all but document nodes and elements from having jqLite.data() set both in the compiler and in ng-view. Fixes: #1968 and #1876 --- src/ng/compile.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/ng/compile.js') diff --git a/src/ng/compile.js b/src/ng/compile.js index 18adc2c9..2ed34f73 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -330,7 +330,14 @@ function $CompileProvider($provide) { var $linkNode = cloneConnectFn ? JQLitePrototype.clone.call($compileNodes) // IMPORTANT!!! : $compileNodes; - $linkNode.data('$scope', scope); + + // Attach scope only to non-text nodes. + for(var i = 0, ii = $linkNode.length; i