]> source.dussan.org Git - jquery.git/commitdiff
Event: Copy detail property to jQuery.Event on native events
authorDave Methvin <dave.methvin@gmail.com>
Wed, 3 Dec 2014 20:56:50 +0000 (15:56 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Wed, 3 Dec 2014 20:56:50 +0000 (15:56 -0500)
Fixes gh-1867

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

index aee6cb78fe62ac4ca2970081ae2d5dfbfbc208d5..44961ef7de846f73160ca0e86c95ad5c6c4e2c26 100644 (file)
@@ -460,7 +460,7 @@ jQuery.event = {
        },
 
        // Includes some event props shared by KeyEvent and MouseEvent
-       props: ( "altKey bubbles cancelable ctrlKey currentTarget eventPhase " +
+       props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
                "metaKey relatedTarget shiftKey target timeStamp view which" ).split(" "),
 
        fixHooks: {},
index 8572c952bb3c176a0b2ac5b91e9c573cb2cb6bdd..652d839456c424fa200fef6858e89ae8a06c5c41 100644 (file)
@@ -2381,6 +2381,25 @@ test("hover event no longer special since 1.9", function() {
                .off("hover");
 });
 
+test( "event object properties on natively-triggered event", function() {
+       expect( 3 );
+
+       var link = document.createElement( "a" ),
+               $link = jQuery( link ),
+               evt = document.createEvent( "MouseEvents" );
+
+       // IE9+ requires element to be in the body before it will dispatch
+       $link.appendTo( "body" ).on( "click", function( e ) {
+               // Not trying to assert specific values here, just ensure the property exists
+               equal( "detail" in e, true, "has .detail" );
+               equal( "cancelable" in e, true, "has .cancelable" );
+               equal( "bubbles" in e, true, "has .bubbles" );
+       });
+       evt.initEvent( "click", true, true );
+       link.dispatchEvent( evt );
+       $link.off( "click" ).remove();
+});
+
 test("fixHooks extensions", function() {
        expect( 2 );