Sign up (with export icon)

utils/dom/geteventroots

Api-module iconmodule

Functions

  • Chevron-right icon

    getEventRoots( node ) → Array<Document | ShadowRoot>

    Returns every event root of the given node: the shadow roots it renders in, innermost first, followed by the document it is connected to.

    For code that listens to the DOM events of a node, which a listener on document alone may miss: events that are not composed, such as scroll, never leave the shadow root they started in, and the events that do are retargeted to the shadow host. Works for open and closed roots alike.

    Like getShadowRoots, it reports the shadow roots of a detached node too. The document is only included while the node is connected to it. Empty for null.

    Parameters

    node: Node | null

    The node to collect the event roots of.

    Returns

    Array<Document | ShadowRoot>