-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Changed event.js to add "code" property to keyboard event object #3998
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
Changed event.js to add "code" property to keyboard event object #3998
Conversation
dmethvin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We're not testing all properties of jQuery.Event so I think the lack of a test is fine. As for docs, can you add a PR to update this line in the API docs?
Shouldn't we test them all? (this is not related to this PR, just a general question) |
|
Not all properties that we lazy-copy are on all events that the browser can generate, and (at least last I checked) not all the properties are supported by all browsers. We'd need a matrix of event names and valid properties for the event by browser that could cover at least most of them. To ensure we copy correctly from a native event we would need to dispatch a native event, and the mechanism to do that is browser-dependent as well right now--some support the newer event constructors and some only support the DOM2 |
|
@dmethvin My main worry is that some future refactor that will move this code to a different place will lose one of the properties and we won't notice. To prevent that we don't really need to test with real event objects, just mocking it would suffice. Obviously, that would amount to just duplicating the event name list in tests without testing the substance but it still seems a little bit more secure than what we have now. |
|
I will update the API docs asap and I can also add a new test if you think it will be necessary for this update. |
|
We could just do a super-dumb test and make sure that all of these properties are actually on the jQuery.Event prototype. |
Summary
Added the "code" property to the Event object passed to keyboard-triggered event handlers, as suggested on #3978.
Checklist