]> source.dussan.org Git - jquery.git/commitdiff
Event: Normalize mouse event properties in drag events
authorAditya Raghavan <araghavan3@gmail.com>
Sat, 20 Dec 2014 23:41:24 +0000 (18:41 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Mon, 5 Jan 2015 20:34:52 +0000 (15:34 -0500)
DragEvent is a superset of MouseEvent, so we want to fix up mouse
properties like pageX and pageY.

Fixes gh-1925

src/event.js
test/unit/event.js

index 93b68d25f2ff5df5c4e85e599b4f53b1d06a2361..11b2ea9048619df7eb9381149a80e32bcd773c24 100644 (file)
@@ -14,7 +14,7 @@ define([
 
 var
        rkeyEvent = /^key/,
-       rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
+       rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/,
        rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
        rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
 
index 8e33c6b9030c7753b43847196d351ee2db6cda9b..d3a7ef231505599ae49528d86d621d32672bdc51 100644 (file)
@@ -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 );