Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix($compile): Major Memory Leak in Directive '&' attribute #6807

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1462,9 +1462,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 @@ -1809,7 +1807,18 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
});
}
}

/**
* Wrapper for '&' One-way binding to prevent memory leak.
* Backport from 1.3.x fix for bug #6794.
* @param {function} parentGet Gets value from parent
* @param {ng.$rootScope.Scope} scope Target Scope
* @return {function} & Binding Fn
*/
function parentGetFn(parentGet, scope) {
return function (locals) {
return parentGet(scope, locals);
};
}

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