Skip to content

Commit 97cf528

Browse files
araghavadmethvin
authored andcommitted
Event: Normalize mouse event properties in drag events
DragEvent is a superset of MouseEvent, so we want to fix up mouse properties like pageX and pageY. Fixes jquerygh-1925
1 parent 66e1b6b commit 97cf528

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
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)|click/,
17+
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/,
1818
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
1919
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
2020

test/unit/event.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,20 @@ 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 );
2449+
2450+
var $fixture = jQuery( "<div id='drag-fixture'></div>" ).appendTo( "body" );
2451+
2452+
$fixture.on( "dragmove", function( evt ) {
2453+
ok( "pageX" in evt, "checking for pageX property" );
2454+
ok( "pageY" in evt, "checking for pageY property" );
2455+
});
2456+
2457+
fireNative( $fixture[ 0 ], "dragmove" );
2458+
$fixture.unbind( "dragmove" ).remove();
2459+
});
2460+
24472461
test( "focusin using non-element targets", function() {
24482462
expect( 2 );
24492463

0 commit comments

Comments
 (0)