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

Define "has event listener" operation #453

Open
annevk opened this issue May 2, 2017 · 8 comments · May be fixed by #660
Open

Define "has event listener" operation #453

annevk opened this issue May 2, 2017 · 8 comments · May be fixed by #660

Comments

@annevk
Copy link
Member

annevk commented May 2, 2017

For whatwg/html#1900, service workers, and a couple of other cases in the platform, we need to determine whether an object has event listeners for a given event type. It would be good to tie these to a single operation that has a little warning alongside pointing out the issues with it.

@gterzian
Copy link
Member

gterzian commented Jun 4, 2018

As an update, I am planning on working on this within the next few weeks... it ended up being implemented in servo/servo@29d1cf6, more or less by re-using the concept of the 'event-path'

@annevk
Copy link
Member Author

annevk commented Jun 4, 2018

Interesting. Why not iterate over the listeners of the EventTarget object's event listener list?

@gterzian
Copy link
Member

gterzian commented Jun 4, 2018

I'm not sure, I think I assumed the entire path had to be checked...

So essentially you mean, taking the linked to implementation as a context, just do target.has_listeners_for(type_) on the one EventTarget and not bother with doing that for all others in the event path for that target?

@annevk
Copy link
Member Author

annevk commented Jun 4, 2018

Yeah, I think that's what https://searchfox.org/mozilla-central/rev/ae8c2e2354db652950fe0ec16983360c21857f2a/dom/events/EventListenerManager.cpp#1609-1620 and its callers do so that would match what implementations do.

@gterzian
Copy link
Member

gterzian commented Jun 4, 2018

Thanks, I'll investigate further and update the Servo implementation.

@domenic
Copy link
Member

domenic commented Oct 12, 2020

whatwg/html#5889 removed "if any event listeners were triggered" from HTML, so this seems to reduce to #660.

@annevk
Copy link
Member Author

annevk commented Dec 15, 2020

@jakearchibald @jungkees so I guess only service workers still needs this hook? Does #660 work for you?

@annevk
Copy link
Member Author

annevk commented Mar 1, 2021

XMLHttpRequest also needs this

If one or more event listeners are registered on this’s upload object, then set this’s upload listener flag.

and has a test at xhr/event-upload-progress.any.js.

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

Successfully merging a pull request may close this issue.

3 participants