Skip to content

Should ShadowRootEventMap have more events? #1527

Open

Description

Events in a shadow DOM can bubble up to the shadow root and can be listened to on the ShadowRoot objects.

Thus I think ShadowRootEventMap should include more events, probably extending GlobalEventHandlersEventMap.

Activity

  1. saschanaz commented on Mar 22, 2023

    @saschanaz
    Contributor

    Sounds right, and I'd like to solve this in HTML spec instead (because ShadowRoot does not include GlobalEventHandlers right now). Can you open an issue there (and perhaps link back here)?

  2. Fxxxlei commented on Mar 22, 2023

    @Fxxxlei
    Author

    There already seems to be an issue referring to a few more inconsistencies involving event bubbling: whatwg/dom#1097

  3. AshleyScirra commented on Jul 24, 2026

    @AshleyScirra

    Just ran in to this. Events like "pointerdown" are allowed to be added to ShadowRoot and work correctly in practice, but are missing from ShadowRootEventMap, and so legal code can be incorrectly marked as an error. Example:

    const shadowRoot = new ShadowRoot();
    function handlePointerDown(e: PointerEvent) {}
    
    // Error: Argument of type 'Event' is not assignable to parameter of type 'PointerEvent'
    shadowRoot.addEventListener("pointerdown", e => handlePointerDown(e));

    Workaround: write handlePointerDown(e as PointerEvent).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions