Web APIs
Element.shadowRoot
Returns the accessible open shadow root, or null if none or closed.
Formal Syntax & Structure
javascript syntaxjavascript
host.shadowRootReturn Value
ShadowRoot | null
Returns the accessible open shadow root, or null if none or closed.
Working Example
Example Snippetjavascript
(async () => {const host=document.createElement("div");const root=host.attachShadow({mode:"closed"});console.log(host.shadowRoot===null,root.host===host);})()