UNPKG

@empathyco/x-components

Version:
27 lines (15 loc) 1.1 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [getActiveElement](./x-components.getactiveelement.md) ## getActiveElement() function Retrieves the currently active element from the specified document or shadow root. This function is recursive to handle nested shadow DOMs, ensuring the actual active element is returned even if it resides deep within multiple shadow DOM layers. **Signature:** ```typescript export declare function getActiveElement(root?: Document | ShadowRoot): Element | null; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | root | Document \| ShadowRoot | _(Optional)_ The root document or shadow root from which to retrieve the active element. Defaults to the global document if not specified. | **Returns:** Element \| null The active element if one exists, or null if no active element can be found. In the context of shadow DOM, this will return the deepest active element within nested shadow roots.