Skip to content

Commit

Permalink
fix($compile): fix memory leak
Browse files Browse the repository at this point in the history
For functions that have a '&' binding on the scope, change the
function from an inline definition to an external definition so
the function closure has no access to the parent scope.

Closes angular#6794
  • Loading branch information
lgalfaso committed Mar 22, 2014
1 parent 408d958 commit 23cd1d5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1465,9 +1465,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {

case '&':
parentGet = $parse(attrs[attrName]);
isolateScope[scopeName] = function(locals) {
return parentGet(scope, locals);
};
isolateScope[scopeName] = parentGetFn(parentGet, scope);
break;

default:
Expand Down Expand Up @@ -1813,6 +1811,11 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
}

function parentGetFn(parentGet, scope) {
return function(locals) {
return parentGet(scope, locals);
};
}

function getTrustedContext(node, attrNormalizedName) {
if (attrNormalizedName == "srcdoc") {
Expand Down

0 comments on commit 23cd1d5

Please sign in to comment.