Skip to main content

getActiveElement

function

Returns the focused element within the same Document or ShadowRoot as `node`, using the standard `DocumentOrShadowRoot.activeElement`. Unlike `document.activeElement` — which is retargeted to the outermost shadow host when focus is inside a shadow tree — this returns the focused element within `node`'s own tree (e.g. the editor's contentEditable when it lives inside a shadow root).

function getActiveElement(node: Node): Element | null

Import

import { getActiveElement } from '@modular/sdk/editor';

Notes

returns
The active element, or null.