Skip to content
Snippets Groups Projects
Unverified Commit 685b97a5 authored by Greg Fodor's avatar Greg Fodor Committed by GitHub
Browse files

Merge pull request #60 from mozilla/bug/infinite-loop-in-template-hydration

Bug/infinite loop in template hydration
parents 49b78136 10b0d632
No related branches found
No related tags found
No related merge requests found
...@@ -93,19 +93,16 @@ function attachTemplate(templateEl) { ...@@ -93,19 +93,16 @@ function attachTemplate(templateEl) {
const targetEls = templateEl.parentNode.querySelectorAll(selector); const targetEls = templateEl.parentNode.querySelectorAll(selector);
const clone = document.importNode(templateEl.content, true); const clone = document.importNode(templateEl.content, true);
const templateRoot = clone.firstElementChild; const templateRoot = clone.firstElementChild;
const templateRootAttrs = templateRoot.attributes;
for (var i = 0; i < targetEls.length; i++) {
const targetEl = targetEls[i];
for (const el of targetEls) {
// Merge root element attributes with the target element // Merge root element attributes with the target element
for (var i = 0; i < templateRootAttrs.length; i++) { for (const { name, value } of templateRoot.attributes) {
targetEl.setAttribute(templateRootAttrs[i].name, templateRootAttrs[i].value); el.setAttribute(name, value);
} }
// Append all child elements // Append all child elements
for (var i = 0; i < templateRoot.children.length; i++) { for (const child of templateRoot.children) {
targetEl.appendChild(document.importNode(templateRoot.children[i], true)); el.appendChild(document.importNode(child, true));
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment