ShadowRoot.host

The host read-only property of the ShadowRoot returns a reference to the DOM element the ShadowRoot is attached to.

Syntax

var element = shadowRoot.host

Value

A  DOM Element.

Examples

let customElem = document.querySelector('my-shadow-dom-element');
let shadow = customElem.shadowRoot;

  ...

// return the original host element sometime later
let hostElem = shadow.host;

Specifications

Specification Status Comment
DOM
The definition of 'ShadowRoot.host' in that specification.
Living Standard  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support53 No1592 3 No4010.1
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support5353 No1592 34010.16.0

1. Under consideration

2. See bug 1205323

3. From version 59: this feature is behind the dom.webcomponents.shadowdom.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

Document Tags and Contributors

 Last updated by: ExE-Boss,