]> source.dussan.org Git - jquery.git/commitdiff
Event: HTML5 drop events inherit from MouseEvent
authorDave Methvin <dave.methvin@gmail.com>
Wed, 14 Jan 2015 19:34:09 +0000 (14:34 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Wed, 14 Jan 2015 19:34:09 +0000 (14:34 -0500)
Fixes gh-2009
Ref gh-1925

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

index f17a1de7790b844772381203164376cfe965e5b1..238c96269ba5e14a68054af1a339e5968e181ee1 100644 (file)
@@ -14,7 +14,7 @@ define([
 
 var
        rkeyEvent = /^key/,
-       rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/,
+       rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
        rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
        rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
 
index d3a7ef231505599ae49528d86d621d32672bdc51..fef9e05fb9657b9f733bbeb2fb4c2133db3dab13 100644 (file)
@@ -2444,18 +2444,25 @@ test("fixHooks extensions", function() {
        jQuery.event.fixHooks.click = saved;
 });
 
-test( "drag events copy over mouse related event properties (gh-1925)", function() {
-       expect( 2 );
+test( "drag/drop events copy mouse-related event properties (gh-1925, gh-2009)", function() {
+       expect( 4 );
 
        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" );
+               ok( "pageX" in evt, "checking for pageX property on dragmove" );
+               ok( "pageY" in evt, "checking for pageY property on dragmove" );
        });
-
        fireNative( $fixture[ 0 ], "dragmove" );
-       $fixture.unbind( "dragmove" ).remove();
+
+       $fixture.on( "drop", function( evt ) {
+               ok( "pageX" in evt, "checking for pageX property on drop" );
+               ok( "pageY" in evt, "checking for pageY property on drop" );
+       });
+
+       fireNative( $fixture[ 0 ], "drop" );
+
+       $fixture.unbind( "dragmove drop" ).remove();
 });
 
 test( "focusin using non-element targets", function() {