-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Event: Restore the constructor
property on jQuery.Event prototype
#1580
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
Conversation
@@ -659,7 +659,7 @@ jQuery.Event = function( src, props ) { | |||
|
|||
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding | |||
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html | |||
jQuery.Event.prototype = { | |||
jQuery.extend( jQuery.Event.prototype, { |
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.
It's not a "hot path" but to fix the issue described, the following is sufficient:
jQuery.Event.prototype = {
constructor: jQuery.Event,
...
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.
Yep, the reason I went with $.extend is that as you pointed out, it's not a hot path and it turned out to be 1 byte smaller after gzip. I'm fine doing it either way if you have a preference.
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.
The way I suggested is the correct way to fix the constructor property problem. While I appreciate that attention was paid to the size of the patch, it's not immediately clear that jQuery.extend
is being used to prevent the described problem.
edit
I'd accept the 1 byte cost for correctness.
The original definition of the jQuery.Event prototype was paving over the `constructor` property which was causing jQuery.isPlainObject to improperly report that an instance of jQuery.Event was a plain object.
constructor
property on jQuery.Event prototype
Sounds like we settled on setting the |
The original definition of the jQuery.Event prototype was paving over the `constructor` property which was causing jQuery.isPlainObject to improperly report that an instance of jQuery.Event was a plain object. Fixes #15090 Closes jquerygh-1580 (cherry picked from commit b807aed)
The original definition of the jQuery.Event prototype was paving over the `constructor` property which was causing jQuery.isPlainObject to improperly report that an instance of jQuery.Event was a plain object. Fixes #15090 Closes gh-1580
The original definition of the jQuery.Event prototype was paving over the
constructor
property which was causing jQuery.isPlainObject toimproperly report that an instance of jQuery.Event was a plain object.
Fixes #15090