Web APIs

Element.shadowRoot

Try the free JavaScript compiler

Returns the accessible open shadow root, or null if none or closed.

Formal Syntax & Structure

javascript syntaxjavascript
host.shadowRoot

Return 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);})()
JavaScript Reference