DEV Community

Discussion on: Lets Build Web Components! Part 1: The Standards

Collapse
 
phnx311 profile image
Eric Chi

Hi Benny I've never seen the element method .content from const

clone = template.content.cloneNode(true);

Is this new or just something thats always been available?

Collapse
 
bennypowers profile image
Benny Powers 🇮🇱🇨🇦

Hey Eric thanks for dropping by 🍻

content is a read-only property on HTMLTemplateElement that's not provided on other elements. It's purpose is to give you a handle on the template's contents as a DocumentFragment, so that you can clone it.