diff --git a/src/elements/a-gltf-entity.js b/src/elements/a-gltf-entity.js index afc9522ad3c47eb29e6f4ef6b40b09e88505fd54..ee59e3a24ead224a4095c69c70d2ea0da1c9cbd5 100644 --- a/src/elements/a-gltf-entity.js +++ b/src/elements/a-gltf-entity.js @@ -93,19 +93,16 @@ function attachTemplate(templateEl) { const targetEls = templateEl.parentNode.querySelectorAll(selector); const clone = document.importNode(templateEl.content, true); 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 - for (var i = 0; i < templateRootAttrs.length; i++) { - targetEl.setAttribute(templateRootAttrs[i].name, templateRootAttrs[i].value); + for (const { name, value } of templateRoot.attributes) { + el.setAttribute(name, value); } // Append all child elements - for (var i = 0; i < templateRoot.children.length; i++) { - targetEl.appendChild(document.importNode(templateRoot.children[i], true)); + for (const child of templateRoot.children) { + el.appendChild(document.importNode(child, true)); } } }