shadow root vs. host
EventTarget ⟩ Node ⟩ DocumentFragment ⟩ ShadowRoot ⭐
Google ⟩ Creating shadow DOM
// attach a shadow DOM to element
let root = host.attachShadow({mode: 'open'});
// ⭐️ root.host === host
// ⭐️ host.shadowRoot === root
The shadow host must be either a custom element, or one of: “article”, “aside”, “blockquote”, “body”, “div”, “footer”, “h1…h6”, “header”, “main” “nav”, “p”, “section”, or “span”.
The spec defines a list of elements that can't host a shadow tree.
Last updated
Was this helpful?