Skip to content

Commit d9ed166

Browse files
committed
Event: Copy detail property to jQuery.Event on native events
Fixes gh-1867
1 parent 80022c8 commit d9ed166

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ jQuery.event = {
460460
},
461461

462462
// Includes some event props shared by KeyEvent and MouseEvent
463-
props: ( "altKey bubbles cancelable ctrlKey currentTarget eventPhase " +
463+
props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
464464
"metaKey relatedTarget shiftKey target timeStamp view which" ).split(" "),
465465

466466
fixHooks: {},

test/unit/event.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,6 +2381,25 @@ test("hover event no longer special since 1.9", function() {
23812381
.off("hover");
23822382
});
23832383

2384+
test( "event object properties on natively-triggered event", function() {
2385+
expect( 3 );
2386+
2387+
var link = document.createElement( "a" ),
2388+
$link = jQuery( link ),
2389+
evt = document.createEvent( "MouseEvents" );
2390+
2391+
// IE9+ requires element to be in the body before it will dispatch
2392+
$link.appendTo( "body" ).on( "click", function( e ) {
2393+
// Not trying to assert specific values here, just ensure the property exists
2394+
equal( "detail" in e, true, "has .detail" );
2395+
equal( "cancelable" in e, true, "has .cancelable" );
2396+
equal( "bubbles" in e, true, "has .bubbles" );
2397+
});
2398+
evt.initEvent( "click", true, true );
2399+
link.dispatchEvent( evt );
2400+
$link.off( "click" ).remove();
2401+
});
2402+
23842403
test("fixHooks extensions", function() {
23852404
expect( 2 );
23862405

0 commit comments

Comments
 (0)