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
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- elrequiredHTMLElement
- 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.
- callbackrequired(root: Document | ShadowRoot) => void
- The action to run on each applicable root. Typically adds or removes an event listener.
API
Return value
The value returned by this util.
- Nothing. Purely side-effectful.
Usage
Examples
Ready-to-paste usage snippets.
Register a click-outside listener across the shadow boundary