Skip to content

Tag: html-templates

Why does not DocumentFragment has getElementsByName?

I am following the instructions given on MDN to use <template>. Slightly different those give in example, my code is: However, it appears that item, of which the __proto__ is DocumentFragment has no getElementsByName method. Is it very confusing for me now that there is getElementById and querySelector. Is there any reason why? In case related, my browsers are FireFox

Initialisation of Custom Elements Inside Document Fragment

Consider this HTML template with two flat x-elements and one nested. How to initialise (fire constructor) all custom elements in cloned from fooTemplate document fragment without appending it to DOM, neither by extending built-in elements with is=”x-element”; either entire fragment. Note that script executes with defer attribute. Answer We can initialise template with this arrow function: Or with this method