-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
EventListener is limiting #55
Comments
Seconded... Exposing the raw event object would make things more flexible... Exposing these as methods on the handler is neat, but it always struck me as a bit weird. In fact, the first time I needed to use preventDefault, I spent quite a while scratching my head and referring to examples before I worked it out. It's a lot more familiar to call it within the event handler, and not being able to call it conditionally is an important omission. p.s. We recently fixed this to expose stopPropagation in the same way as preventDefault. |
The initial idea for that Keep in mind that React still sees a reason for adding an abstraction on the native event: https://facebook.github.io/react/docs/events.html This might be especially necessary when we add event pooling for performance. |
From @davelondon
From @shurcooL
From @slimsag
|
From React's event documentation it seems like the main reason they use synthetic events is to standardize how events act across browsers. That actually feels a bit strange to do IMO, but I do not know all the details I suppose. They too, also expose the native event:
And event pooling appears to just be for purposes of not creating the same JS object over and over again (something that could be achieved by simply using the event object the browser gives us). I think they might do more behind the scenes to improve event performance, but I think for now it is OK for us to expose native event objects. |
I've noticed when working on a project that
EventListener
can be limiting in regard to the fact that we don't expose the raw*js.Object
event OR similiar functionality.For example, in one scenario I wanted to call
preventDefault
on the event object within the event handler, i.e. dependent upon a condition within my event handler. Particularly, if a specific key was pressed I would callpreventDefault
but if it wasn't a specific key then I would retain the default behavior by not callingpreventDefault
. Right now, however, it is only possible to callPreventDefault
as a blanket-statement for the entire event handler -- not conditionally -- because we don't expose the raw event nor such a method to do it conditionally (it can only be done on theEventHandler
object, which the callback has no access to).The text was updated successfully, but these errors were encountered: