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.
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-nolint
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
## See also
- Element.shadowRoot
- [`chrome.dom.openOrClosedShadowRoot`](https://developer.chrome.com/docs/extensions/reference/api/dom#method-openOrClosedShadowRoot)
Cite this
"dom.openOrClosedShadowRoot()". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/dom/openOrClosedShadowRoot JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy