From: Dave Methvin Date: Wed, 14 Jan 2015 19:34:09 +0000 (-0500) Subject: Event: HTML5 drop events inherit from MouseEvent X-Git-Tag: 3.0.0-alpha1~137 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d7e5fcee519e5f3e840beef9e67a536e75133df9;p=jquery.git Event: HTML5 drop events inherit from MouseEvent Fixes gh-2009 Ref gh-1925 --- diff --git a/src/event.js b/src/event.js index f17a1de77..238c96269 100644 --- a/src/event.js +++ b/src/event.js @@ -14,7 +14,7 @@ define([ var rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/, + rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, rtypenamespace = /^([^.]*)(?:\.(.+)|)/; diff --git a/test/unit/event.js b/test/unit/event.js index d3a7ef231..fef9e05fb 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2444,18 +2444,25 @@ test("fixHooks extensions", function() { jQuery.event.fixHooks.click = saved; }); -test( "drag events copy over mouse related event properties (gh-1925)", function() { - expect( 2 ); +test( "drag/drop events copy mouse-related event properties (gh-1925, gh-2009)", function() { + expect( 4 ); var $fixture = jQuery( "
" ).appendTo( "body" ); $fixture.on( "dragmove", function( evt ) { - ok( "pageX" in evt, "checking for pageX property" ); - ok( "pageY" in evt, "checking for pageY property" ); + ok( "pageX" in evt, "checking for pageX property on dragmove" ); + ok( "pageY" in evt, "checking for pageY property on dragmove" ); }); - fireNative( $fixture[ 0 ], "dragmove" ); - $fixture.unbind( "dragmove" ).remove(); + + $fixture.on( "drop", function( evt ) { + ok( "pageX" in evt, "checking for pageX property on drop" ); + ok( "pageY" in evt, "checking for pageY property on drop" ); + }); + + fireNative( $fixture[ 0 ], "drop" ); + + $fixture.unbind( "dragmove drop" ).remove(); }); test( "focusin using non-element targets", function() {