Permalink
Browse files

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 gh-1925
  • Loading branch information...
araghava authored and dmethvin committed Dec 20, 2014
1 parent 66e1b6b commit 97cf5280824027c3d4fcdbb4db49c10ad3c62bce
Showing with 15 additions and 1 deletion.
  1. +1 −1 src/event.js
  2. +14 −0 test/unit/event.js
View
@@ -14,7 +14,7 @@ define([
var
rkeyEvent = /^key/,
- rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
+ rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
View
@@ -2444,6 +2444,20 @@ test("fixHooks extensions", function() {
jQuery.event.fixHooks.click = saved;
});
+test( "drag events copy over mouse related event properties (gh-1925)", function() {
+ expect( 2 );
+
+ var $fixture = jQuery( "<div id='drag-fixture'></div>" ).appendTo( "body" );
+
+ $fixture.on( "dragmove", function( evt ) {
+ ok( "pageX" in evt, "checking for pageX property" );
+ ok( "pageY" in evt, "checking for pageY property" );
+ });
+
+ fireNative( $fixture[ 0 ], "dragmove" );
+ $fixture.unbind( "dragmove" ).remove();
+});
+
test( "focusin using non-element targets", function() {
expect( 2 );

0 comments on commit 97cf528

Please sign in to comment.