Skip to content

Commit a05de40

Browse files
committed
Event: HTML5 drop events inherit from MouseEvent
Fixes gh-2009 Ref gh-1925 (cherry picked from commit d7e5fce) Conflicts: test/unit/event.js
1 parent 87bb713 commit a05de40

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/event.js

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

1313
var rformElems = /^(?:input|select|textarea)$/i,
1414
rkeyEvent = /^key/,
15-
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/,
15+
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
1616
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
1717
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
1818

test/unit/event.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,21 +2481,26 @@ test("fixHooks extensions", function() {
24812481
// this test in IE8 since a native HTML5 drag event will never occur there.
24822482
if ( document.createEvent ) {
24832483

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

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

24892489
$fixture.on( "dragmove", function( evt ) {
2490-
ok( "pageX" in evt, "checking for pageX property" );
2491-
ok( "pageY" in evt, "checking for pageY property" );
2490+
ok( "pageX" in evt, "checking for pageX property on dragmove" );
2491+
ok( "pageY" in evt, "checking for pageY property on dragmove" );
24922492
});
2493-
24942493
fireNative( $fixture[ 0 ], "dragmove" );
2495-
$fixture.unbind( "dragmove" ).remove();
2494+
2495+
$fixture.on( "drop", function( evt ) {
2496+
ok( "pageX" in evt, "checking for pageX property on drop" );
2497+
ok( "pageY" in evt, "checking for pageY property on drop" );
2498+
});
2499+
fireNative( $fixture[ 0 ], "drop" );
2500+
2501+
$fixture.unbind( "dragmove drop" ).remove();
24962502
});
24972503
}
2498-
24992504
test( "focusin using non-element targets", function() {
25002505
expect( 2 );
25012506

0 commit comments

Comments
 (0)