handleShadow

Commons
stable

Invokes a callback on the document root and additionally on the element's Shadow Root when the element is inside a Shadow DOM. Used by click-outside and similar directives to register / unregister listeners across the shadow boundary.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

el
requis
HTMLElement
The element whose root is inspected. If it lives inside a ShadowRoot the callback is invoked twice: once for the global document and once for the shadow root.
callback
requis
(root: Document | ShadowRoot) => void
The action to run on each applicable root. Typically adds or removes an event listener.

API

Valeur de retour

La valeur retournée par cet util.

Nothing. Purely side-effectful.

Usage

Exemples

Extraits de code prêts à coller.

Register a click-outside listener across the shadow boundary

typescript