# utils/dom/getelementfrompoint

module

<a id="functions">

## Functions

<a id="function-getElementFromPoint">

### `getElementFromPoint( x, y, shadowRoots ) → Element | null`

Returns the topmost element at the given viewport point, looking inside the given shadow roots.

The shadow-aware replacement for `Document#elementFromPoint()`, which retargets a point inside a shadow tree to that tree's host and so cannot report the element actually under it.

Pass every shadow root a hit may land in – typically each editable's own `getRootNode()`. Only the innermost root containing the point matters, so ancestor roots do not need to be listed, and a point in the light DOM needs no roots at all.

The point is hit tested strictly, honoring `pointer-events`, so the answer is the element that a click at those coordinates would reach. The exception is an engine that cannot hit test a shadow root, where the point is resolved from the nearest caret position instead and may land beside what it really hit.

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

#### Parameters

* `x: number`

  The horizontal coordinate, relative to the viewport.

* `y: number`

  The vertical coordinate, relative to the viewport.

* `shadowRoots: Array<ShadowRoot>`

  The shadow roots the lookup is allowed to look inside. Empty for the light DOM.

  Defaults to `[]`

#### Returns

* `Element | null`

---

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