Skip to content

Commit 0a943b8

Browse files
committed
fix($compile): work around Firefox DocumentFragment bug
DOM nodes passed to `compilationGenerator()` will eventually be wrapped in `jqLite`, when the compilation actually happens. In Firefox 60+, there seems to be a `DocumentFragment`-related bug that sometimes causes the `childNodes` to be empty at the time the compilation happens. This commit works around this bug by eagerly wrapping `childNodes` in `jqLite`. NOTE: The wrapped nodes have references to their `DocumentFragment` container. This is "by design", since we want to be able to traverse the nodes via `nextSibling` (in order to correctly handle multi-element directives). Once the nodes are compiled, they will be either moved to a new container element or the `jqLite` wrapper is release making them eligible for garbage collection. In both cases, the original `DocumentFragment` container should be eligible for garbage collection too. Fixes angular#16607
1 parent 66fdf2a commit 0a943b8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ng/compile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,11 +2620,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
26202620
for (var slotName in slots) {
26212621
if (slots[slotName]) {
26222622
// Only define a transclusion function if the slot was filled
2623-
slots[slotName] = compilationGenerator(mightHaveMultipleTransclusionError, slots[slotName].childNodes, transcludeFn);
2623+
var slotCompileNodes = jqLite(slots[slotName].childNodes);
2624+
slots[slotName] = compilationGenerator(mightHaveMultipleTransclusionError, slotCompileNodes, transcludeFn);
26242625
}
26252626
}
26262627

2627-
$template = $template.childNodes;
2628+
$template = jqLite($template.childNodes);
26282629
}
26292630

26302631
$compileNode.empty(); // clear contents

0 commit comments

Comments
 (0)