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

Commit e34ef23

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 bbd3db1 commit e34ef23

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/ng/compile.js

+11
Original file line numberDiff line numberDiff line change
@@ -2067,6 +2067,17 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20672067
compileNode = $compileNode[0];
20682068
replaceWith(jqCollection, sliceArgs($template), compileNode);
20692069

2070+
// Support: Chrome < 50
2071+
// https://github.com/angular/angular.js/issues/14041
2072+
2073+
// In the versions of V8 prior to Chrome 50, the document fragment that is created
2074+
// in the `replaceWith` function is improperly garbage collected despite still
2075+
// being referenced by the `parentNode` property of all of the child nodes. By adding
2076+
// a reference to the fragment via a different property, we can avoid that incorrect
2077+
// behavior.
2078+
// TODO: remove this line after Chrome 50 has been released
2079+
$template[0].$$parentNode = $template[0].parentNode;
2080+
20702081
childTranscludeFn = compilationGenerator(mightHaveMultipleTransclusionError, $template, transcludeFn, terminalPriority,
20712082
replaceDirective && replaceDirective.name, {
20722083
// Don't pass in:

0 commit comments

Comments
 (0)