dom.openOrClosedShadowRoot()

Gets the open shadow root or the closed shadow root hosted by the specified element. If the shadow root isn't attached to the element, it will return null.

Note: In Firefox, the equivalent property is element.openOrClosedShadowRoot. This read-only property represents the shadow root hosted by the element, regardless of whether its mode is open or closed.

Use Element.attachShadow() to add a shadow root to an element.

Syntax

js
let shadowRoot = browser.dom.openOrClosedShadowRoot(
  element,    // HTMLElement
)

Parameters

element

HTMLElement. The host element.

Return value

A ShadowRoot object instance, regardless of whether its mode is set to open or closed, or null if no shadow root is present.

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
openOrClosedShadowRoot
Chrome – Full support
Chrome 88 (Release date: 2021-01-19)
footnote Full support
Edge – Full support
Edge 88 (Release date: 2021-01-21)
footnote Full support
Firefox – No support
Firefox
footnote
footnote Use element.openOrClosedShadowRoot, available since Firefox 63.
Opera – Full support
Opera 74 (Release date: 2021-02-02)
footnote Full support
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote
footnote Use element.openOrClosedShadowRoot, available since Firefox for Android 63.
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

See also