Skip to content

Commit b807aed

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 jquerygh-1580
1 parent 1ae025e commit b807aed

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
@@ -672,6 +672,7 @@ jQuery.Event = function( src, props ) {
672672
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
673673
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
674674
jQuery.Event.prototype = {
675+
constructor: jQuery.Event,
675676
isDefaultPrevented: returnFalse,
676677
isPropagationStopped: returnFalse,
677678
isImmediatePropagationStopped: returnFalse,

test/unit/event.js

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

14431443
test("jQuery.Event( type, props )", function() {
14441444

1445-
expect(5);
1445+
expect(6);
14461446

14471447
var event = jQuery.Event( "keydown", { keyCode: 64 }),
14481448
handler = function( event ) {
@@ -1458,6 +1458,8 @@ test("jQuery.Event( type, props )", function() {
14581458

14591459
ok( "keyCode" in event, "Special 'keyCode' property exists" );
14601460

1461+
strictEqual( jQuery.isPlainObject( event ), false, "Instances of $.Event should not be identified as a plain object." );
1462+
14611463
jQuery("body").on( "keydown", handler ).trigger( event );
14621464

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

0 commit comments

Comments
 (0)