Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardHTMLdeclarative shadow DOMSingle-choice MCQ

Why does innerHTML assignment NOT create a shadow root from a <template shadowrootmode> string, while DOMParser.parseFromString with the right option does?

// case 1 el.innerHTML = '<template shadowrootmode="open">x</template>'; // case 2 new DOMParser().parseFromString( '<div><template shadowrootmode="open">x</template></div>', 'text/html', { /* ... */ } );