Permalink
Browse files

Event: HTML5 drop events inherit from MouseEvent

Fixes gh-2009
Ref gh-1925
  • Loading branch information...
dmethvin committed Jan 14, 2015
1 parent 74ae544 commit d7e5fcee519e5f3e840beef9e67a536e75133df9
Showing with 14 additions and 7 deletions.
  1. +1 −1 src/event.js
  2. +13 −6 test/unit/event.js
View
@@ -14,7 +14,7 @@ define([
var
rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag)|click/,
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,

This comment has been minimized.

Show comment
Hide comment
@mgol

mgol Jan 15, 2015

Member

This is only drop so why not:

/^(?:mouse|pointer|contextmenu|drag)|drop|click/

?

@mgol

mgol Jan 15, 2015

Member

This is only drop so why not:

/^(?:mouse|pointer|contextmenu|drag)|drop|click/

?

This comment has been minimized.

Show comment
Hide comment
@dmethvin

dmethvin Jan 15, 2015

Member

That would match something like raindrops as well. The ^ at the front only binds to the first alternate. The treatment of click there allows it to match doubleclick. The way it is now it at least makes the string start with drop and not just have drop somewhere inside it.

Since these are only browser-generated events and not custom ones the difference between the two probably doesn't matter. Well, until some browser creates a native event starting with drop that shouldn't be enhanced with mouse properties. 😈

@dmethvin

dmethvin Jan 15, 2015

Member

That would match something like raindrops as well. The ^ at the front only binds to the first alternate. The treatment of click there allows it to match doubleclick. The way it is now it at least makes the string start with drop and not just have drop somewhere inside it.

Since these are only browser-generated events and not custom ones the difference between the two probably doesn't matter. Well, until some browser creates a native event starting with drop that shouldn't be enhanced with mouse properties. 😈

This comment has been minimized.

Show comment
Hide comment
@mgol

mgol Jan 15, 2015

Member
@mgol

mgol via email Jan 15, 2015

Member
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
View
@@ -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() {

0 comments on commit d7e5fce

Please sign in to comment.