Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event.composedPath() inconsistency between implementors. #1201

Open
Jack-Works opened this issue May 22, 2023 · 5 comments
Open

Event.composedPath() inconsistency between implementors. #1201

Jack-Works opened this issue May 22, 2023 · 5 comments
Labels
interop Implementations are not interoperable with each other topic: events

Comments

@Jack-Works
Copy link

For code

const target = new EventTarget()
target.addEventListener('change', (event) => {
    console.log(event.composedPath())
}, { once: true })
const event = new Event('change')
target.dispatchEvent(event)

Chrome and Safari prints [], Firefox prints [target]

https://dom.spec.whatwg.org/#dom-event-composedpath

Per spec, it looks like Firefox is correct.

@annevk annevk added interop Implementations are not interoperable with each other topic: events labels May 22, 2023
@annevk
Copy link
Member

annevk commented May 22, 2023

I think that's right. Would you be willing to add web-platform-tests coverage? Edit: there are some tests for composedPath() in the /shadow-dom/ directory, not nothing covering this. Perhaps even better to add to /dom/events/ given that shadow trees are not involved in your scenario.

cc @rniwa @mfreed7

@Jack-Works
Copy link
Author

I wonder which behavior is expected? Since the name composedPath indicates it is for DOM Node, the list missing pure EventTarget might be intended.

@annevk
Copy link
Member

annevk commented May 22, 2023

Fair, might be good to wait a bit for others to chime in. In my mind this was always the event's path, but we didn't call it that because it had to be partially obscured in the presence of shadow trees. So I would expect Firefox's behavior and if we ever added the ability for userland EventTarget to hook into "get the parent" that would be reflected here as well.

(These days we would probably not add an API that so casually reveals open shadow trees however.)

cc @smaug----

@bathos
Copy link

bathos commented May 26, 2023

the name composedPath indicates it is for DOM Node

I’m unsure what about the name suggests that. While EventTargets constructed directly from user code never have a non-default “get the parent” algorithm presently, IndexedDB interfaces extending EventTarget do — an IDBRequest’s parent is an IDBTransaction and an IDBTransaction’s parent is an IDBDatabase. The usual bubbling behavior applies.

As far as I can tell, composedPath() for e.g. an IDBRequest success event should reflect this, and in Firefox, it does:

image

In Chromium presently, I get an empty array.

@Jack-Works
Copy link
Author

So should I open the issue in Chrome and Safari?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other topic: events
Development

No branches or pull requests

4 participants
@annevk @Jack-Works @bathos and others