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

Commit 513199e

Browse files
dchermanNarretz
authored andcommitted
fix($compile): workaround a GC bug in Chrome < 50
In the version of V8 used in Chrome < 50, the parent of template nodes for `transclude: "element"` directives would be improperly garbage collected despite still having been referenced via `parentNode`. This bug surfaced due to the introduction of lazy transclusion (652b83e), and appears under certain circumstances when using directive start and end elements. It should be removed some time after Chrome 50 has been released. Fixes #14041 Closes #14286
1 parent 33f3c40 commit 513199e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/ng/compile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,17 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20802080
compileNode = $compileNode[0];
20812081
replaceWith(jqCollection, sliceArgs($template), compileNode);
20822082

2083+
// Support: Chrome < 50
2084+
// https://github.com/angular/angular.js/issues/14041
2085+
2086+
// In the versions of V8 prior to Chrome 50, the document fragment that is created
2087+
// in the `replaceWith` function is improperly garbage collected despite still
2088+
// being referenced by the `parentNode` property of all of the child nodes. By adding
2089+
// a reference to the fragment via a different property, we can avoid that incorrect
2090+
// behavior.
2091+
// TODO: remove this line after Chrome 50 has been released
2092+
$template[0].$$parentNode = $template[0].parentNode;
2093+
20832094
childTranscludeFn = compilationGenerator(mightHaveMultipleTransclusionError, $template, transcludeFn, terminalPriority,
20842095
replaceDirective && replaceDirective.name, {
20852096
// Don't pass in:

0 commit comments

Comments
 (0)