diff options
| author | Pete Bacon Darwin | 2013-02-18 12:05:16 +0000 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-02-18 12:05:16 +0000 |
| commit | 791804bdbfa6da7a39283623bd05628a01cd8720 (patch) | |
| tree | b5745caf3351cbc7723a7ab83720b02b088f851e /src/ng/compile.js | |
| parent | 7eafbb98c64c0dc079d7d3ec589f1270b7f6fea5 (diff) | |
| download | angular.js-791804bdbfa6da7a39283623bd05628a01cd8720.tar.bz2 | |
fix(compile): should not leak memory when there are top level empty text nodes
The change to prevent <span> 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
Diffstat (limited to 'src/ng/compile.js')
| -rw-r--r-- | src/ng/compile.js | 9 |
1 files changed, 8 insertions, 1 deletions
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<ii; i++) { + var node = $linkNode[i]; + if (node.nodeType == 1 /* element */ || node.nodeType == 9 /* document */) { + $linkNode.eq(i).data('$scope', scope); + } + } safeAddClass($linkNode, 'ng-scope'); if (cloneConnectFn) cloneConnectFn($linkNode, scope); if (compositeLinkFn) compositeLinkFn(scope, $linkNode, $linkNode); |
