Skip to content

Commit

Permalink
Event: HTML5 drop events inherit from MouseEvent
Browse files Browse the repository at this point in the history
Fixes gh-2009
Ref gh-1925
(cherry picked from commit d7e5fce)

Conflicts:
	test/unit/event.js
  • Loading branch information
dmethvin committed Jan 14, 2015
1 parent 87bb713 commit a05de40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = /^([^.]*)(?:\.(.+)|)/;

Expand Down
19 changes: 12 additions & 7 deletions test/unit/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down

0 comments on commit a05de40

Please sign in to comment.