]> 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:45:44 +0000 (14:45 -0500)
Fixes gh-2009
Ref gh-1925
(cherry picked from commit d7e5fcee519e5f3e840beef9e67a536e75133df9)

Conflicts:
test/unit/event.js

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

index eb9dd8fc82109b14c26ff94507d02ac19a39a760..f19a7fa1b1807d4abeebf33e805422cdc677fa82 100644 (file)
@@ -12,7 +12,7 @@ define([
 
 var rformElems = /^(?:input|select|textarea)$/i,
        rkeyEvent = /^key/,
-       rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/,
+       rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
        rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
        rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
 
index 8992a0b957ea03cfb69706ac08e5b5e16b1e61fc..3854a2133ba9c5afbc2e309172cc390a0c8ff4f4 100644 (file)
@@ -2481,21 +2481,26 @@ test("fixHooks extensions", function() {
 // this test in IE8 since a native HTML5 drag event will never occur there.
 if ( document.createEvent ) {
 
-       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() {
        expect( 2 );