# utils/dom/containsnode

module

<a id="functions">

## Functions

<a id="function-containsNode">

### `containsNode( container, node ) → boolean`

Checks whether `node` is inside `container`, looking through shadow roots on the way.

Use it instead of `Node#contains()`, which stops at a shadow root: that one says `false` even when `container` really is an ancestor, as long as a shadow root sits between the two. A node contains itself here, just like it does there.

`container` can also be a `Document` or a `ShadowRoot` – useful for a `scroll` event, for example, whose target is the document and not an element. Works with open and closed shadow roots.

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

#### Parameters

* `container: Node`

  The node that may be the ancestor.

* `node: Node | null`

  The node to look for. May be `null`, which always gives `false`.

#### Returns

* `boolean`

---

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