Skip to content

Commit d4a998f

Browse files
dchermangibson042
authored andcommitted
Event: Restore the constructor property on jQuery.Event prototype
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 (cherry picked from commit b807aed)
1 parent 787ffbf commit d4a998f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/event.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ jQuery.Event = function( src, props ) {
728728
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
729729
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
730730
jQuery.Event.prototype = {
731+
constructor: jQuery.Event,
731732
isDefaultPrevented: returnFalse,
732733
isPropagationStopped: returnFalse,
733734
isImmediatePropagationStopped: returnFalse,

test/unit/event.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ if ( window.onbeforeunload === null &&
15111511

15121512
test("jQuery.Event( type, props )", function() {
15131513

1514-
expect(5);
1514+
expect(6);
15151515

15161516
var event = jQuery.Event( "keydown", { keyCode: 64 }),
15171517
handler = function( event ) {
@@ -1527,6 +1527,8 @@ test("jQuery.Event( type, props )", function() {
15271527

15281528
ok( "keyCode" in event, "Special 'keyCode' property exists" );
15291529

1530+
strictEqual( jQuery.isPlainObject( event ), false, "Instances of $.Event should not be identified as a plain object." );
1531+
15301532
jQuery("body").on( "keydown", handler ).trigger( event );
15311533

15321534
jQuery("body").off( "keydown" );

0 commit comments

Comments
 (0)