# utils/dom/getshadowroots

module

<a id="functions">

## Functions

<a id="function-getShadowRoots">

### `getShadowRoots( node ) → Array<ShadowRoot>`

Returns every shadow root the given node renders in, innermost first.

For code that has to act on _all_ the shadow boundaries above a node – attaching listeners, injecting styles – rather than only the nearest one. Empty for a node in the light DOM, and one entry per boundary for a node inside nested trees. Works for open and closed roots alike.

Derived from the tree the node sits in, not from whether that tree is in a document: a node inside a shadow root reports that root even while its host is detached, because `attachShadow()` makes the shadow tree – and its root – real right away. Callers that only care about the roots a node is currently _rendered_ in should check `Node#isConnected` themselves.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/dom/getshadowroots.ts#L27)

#### Parameters

* `node: Node`

  The node to collect the hosting shadow roots of.

#### Returns

* `Array<ShadowRoot>`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
