-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Event: Support EventListener interface objects. #5024
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
base: main
Are you sure you want to change the base?
Event: Support EventListener interface objects. #5024
Conversation
|
Thanks for the PR. Please sign our CLA before we review it. |
I have signed it twice today, but it still says that it is missing. |
The discussion in gh-1735 is pretty old. In that ticket the reason I was referring to the EventListener interface as "low-level" was because I thought it might be useful to use it as a foundation for existing jQuery functionality without exposing EventListener directly in the API. If it's exposed as a top-level ability with I think there may be some other cases and design issues that need to be considered here, especially since we're looking to support new features like passive listeners or the capture phase in jQuery 4. (Passive listeners in particular seem to be something that people want, most likely because Chrome's console complains about them incessantly.) Assuming those issues are resolved or not relevant, the spec says:
However, jQuery's |
Also I just realized that the Mozilla docs seem to indicate the object with
|
Please explain. This PR does not actually pass around and repeatedly accommodate
This solution only affects the second parameter to
Again, this solution is merely a function binding. I can look into adding a unit test to demonstrate
I rapid develop using
but why?
|
The way it's implemented it in this PR nullifies that advantage as there's a strong reference to the handler, it's the handler that's being saved. To be able to fully utilize this, we'd have to actually store the object, not the handler and this should be confirmed by unit tests checking if swapping
We realize this but when you take above into account, there's a lot more complexity to it. Implementing support for passive events requires us to do a significant refactor of our event module while making sure the test suite passes with as few breaking changes as possible. This is just not a good moment to add new significant features like this one. When the refactor is done, we can return to the subject if it's not already handled by the refactor. |
As for the CLA, I've heard the error might be caused by the email used for the commit in this PR not being attached to your GitHub account. Can you make sure that's done? |
Summary
When an event handler implements the
EventListener
interface (by being an object and having a function property calledhandleEvent
), the handler function used internally is replaced with thathandleEvent
function bound to the handler object.http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener
Fixes gh-1735
Checklist