player icon indicating copy to clipboard operation
player copied to clipboard

Event Target is not DOM Element for Web Component Custom Events

Open jlukic opened this issue 6 months ago • 0 comments

I'm testing this with the time-change event emitted from media-player and seeing event.target is not the dom element triggering the event.

Image

It looks like custom events fired from the web component are using event.target to point to the component with a custom getter.

Image

I understand why this was added, it's convenient for attaching to signals, and inspecting other component instance stuff.

However because this is a read only property of an event, systems that rely on event.target to programmatically determine the source of the event will break.

For instance the new version of Semantic UI uses the event.target property to determine if the target event is in the shadow DOM of a nested web component. (It is also commonly used in event delegation patterns although since these events dont bubble its less of a concern).

jlukic avatar Jul 15 '25 21:07 jlukic