-
Notifications
You must be signed in to change notification settings - Fork 303
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
Enable an event listener to be invoked just once #207
Conversation
I wasn't able to find the original request for this (I thought there was even an issue), but if you search for "addeventlistener once" you'll find some Stack Overflow threads requesting this. |
Probably this: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28455 |
You're amazing, marked the bug "MOVED". |
This makes sense to me. I don't know if people would choose to use this (with feature detection / polyfill for the next several years) over just writing the remove code themselves. But it seems like a nice easy little feature to have - even just planning for the far future when developers can depend on it being there. @dtapuska / @tkent-google, what do you think? Pretty trivial to add, right? |
This looks a useful flag. LGTM. |
Spiked out a polyfill implementation for this https://github.com/josh/event-listener-options-polyfill/pull/1 (edit: d'oh, looks like @RByers is already working this) |
The spec should clarify what happens if the callback throws an exception. Based on my interpretation of this:
It sounds like the event listener will be removed even if it doesn't run to completion, but it would be good to clarify this 👍 |
Callbacks throwing never really does anything to event dispatch. (The exceptions are reported per https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke.) Where would you expect to see this clarified? |
Good catch, I missed that part of the spec. |
Vendor feature request bugs: |
No description provided.