From 791804bdbfa6da7a39283623bd05628a01cd8720 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 ++++++++- src/ng/directive/ngView.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/ng') diff --git a/src/ng/compile.js b/src/ng/compile.js index b7eb759b..788231ab 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