DOM Properties
Element.shadowRoot
Returns the accessible open shadow root. Returns null for absent or closed roots. Code retaining a closed root reference can still use it; closed does not protect secrets. Example result: true.
Formal Syntax & Structure
html syntaxhtml
host.shadowRootReturn Value
ShadowRoot | null
Open root or null.
Working Example
Example Snippethtml
<p> Result: <output id="result"></output></p><script> const result = document.getElementById("result"); (async () => { const host = document.createElement("div"); host.attachShadow({mode:"closed"}); result.textContent = host.shadowRoot === null; })().catch(error => { result.textContent = "Error: " + error.name; });</script>