Skip to content

Commit d7e5fce

Browse files
committed
Event: HTML5 drop events inherit from MouseEvent
Fixes gh-2009 Ref gh-1925
1 parent 74ae544 commit d7e5fce

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ define([
1414

1515
var
1616
rkeyEvent = /^key/,
17-
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/,
17+
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
1818
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
1919
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
2020

test/unit/event.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,18 +2444,25 @@ test("fixHooks extensions", function() {
24442444
jQuery.event.fixHooks.click = saved;
24452445
});
24462446

2447-
test( "drag events copy over mouse related event properties (gh-1925)", function() {
2448-
expect( 2 );
2447+
test( "drag/drop events copy mouse-related event properties (gh-1925, gh-2009)", function() {
2448+
expect( 4 );
24492449

24502450
var $fixture = jQuery( "<div id='drag-fixture'></div>" ).appendTo( "body" );
24512451

24522452
$fixture.on( "dragmove", function( evt ) {
2453-
ok( "pageX" in evt, "checking for pageX property" );
2454-
ok( "pageY" in evt, "checking for pageY property" );
2453+
ok( "pageX" in evt, "checking for pageX property on dragmove" );
2454+
ok( "pageY" in evt, "checking for pageY property on dragmove" );
24552455
});
2456-
24572456
fireNative( $fixture[ 0 ], "dragmove" );
2458-
$fixture.unbind( "dragmove" ).remove();
2457+
2458+
$fixture.on( "drop", function( evt ) {
2459+
ok( "pageX" in evt, "checking for pageX property on drop" );
2460+
ok( "pageY" in evt, "checking for pageY property on drop" );
2461+
});
2462+
2463+
fireNative( $fixture[ 0 ], "drop" );
2464+
2465+
$fixture.unbind( "dragmove drop" ).remove();
24592466
});
24602467

24612468
test( "focusin using non-element targets", function() {

0 commit comments

Comments
 (0)