-
Notifications
You must be signed in to change notification settings - Fork 295
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
Expose EventListenerOptions to the event listener when invoked #501
Comments
@benjamingr @MattiasBuelens @jakearchibald @rbuckton @dmethvin I'm curious about your thoughts on this. Apparently jQuery had this feature where you could identify the group a listener belonged to when the listener got invoked. (See #208 (comment).) Does something like that make sense for signals? Would that require the signal to be part of the key so you can register the same listener multiple times with different signals? |
I don't understand the use case. Why should the listener "care" about what addEventHandler options it was registered with? |
The main case I can see is that it allows you to overload a listener so it can handle multiple (likely similar) scenarios. |
Now that you have the signal argument and don't care about a reference to the listener for // Added multiple times, the anonymous functions are no longer an issue
// because we don't need a reference for removeEventListener
target.addEventListener('foo', (e) => myFn(e), { signal });
target.addEventListener('foo', (e) => myFn(e), { signal }); That said, doing what you describe is pretty easy? (and pretty small), just adding a signal to:
I am not sure if it introduces complexity to browsers so I'm hesitant to offer to open a spec PR/WPTs if it's problematic for browsers to add that check when you add or remove a listener. (A potential downside is that it would probably imply |
Thanks! At this point I'm somewhat inclined to close this issue unless someone makes a compelling case. |
Feature request from @grorg. Original at whatwg/html#2959.
The text was updated successfully, but these errors were encountered: