mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
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
This commit is contained in:
parent
1ae025e24f
commit
b807aedb7f
@ -672,6 +672,7 @@ jQuery.Event = function( src, props ) {
|
|||||||
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
// 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
|
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
||||||
jQuery.Event.prototype = {
|
jQuery.Event.prototype = {
|
||||||
|
constructor: jQuery.Event,
|
||||||
isDefaultPrevented: returnFalse,
|
isDefaultPrevented: returnFalse,
|
||||||
isPropagationStopped: returnFalse,
|
isPropagationStopped: returnFalse,
|
||||||
isImmediatePropagationStopped: returnFalse,
|
isImmediatePropagationStopped: returnFalse,
|
||||||
|
@ -1442,7 +1442,7 @@ if ( window.onbeforeunload === null &&
|
|||||||
|
|
||||||
test("jQuery.Event( type, props )", function() {
|
test("jQuery.Event( type, props )", function() {
|
||||||
|
|
||||||
expect(5);
|
expect(6);
|
||||||
|
|
||||||
var event = jQuery.Event( "keydown", { keyCode: 64 }),
|
var event = jQuery.Event( "keydown", { keyCode: 64 }),
|
||||||
handler = function( event ) {
|
handler = function( event ) {
|
||||||
@ -1458,6 +1458,8 @@ test("jQuery.Event( type, props )", function() {
|
|||||||
|
|
||||||
ok( "keyCode" in event, "Special 'keyCode' property exists" );
|
ok( "keyCode" in event, "Special 'keyCode' property exists" );
|
||||||
|
|
||||||
|
strictEqual( jQuery.isPlainObject( event ), false, "Instances of $.Event should not be identified as a plain object." );
|
||||||
|
|
||||||
jQuery("body").on( "keydown", handler ).trigger( event );
|
jQuery("body").on( "keydown", handler ).trigger( event );
|
||||||
|
|
||||||
jQuery("body").off( "keydown" );
|
jQuery("body").off( "keydown" );
|
||||||
|
Loading…
Reference in New Issue
Block a user