]> source.dussan.org Git - jquery.git/commitdiff
Fix #13993. Save result of native inline handlers. Close gh-1368.
authorDave Methvin <dave.methvin@gmail.com>
Thu, 19 Sep 2013 15:34:48 +0000 (11:34 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Sun, 6 Oct 2013 21:58:28 +0000 (17:58 -0400)
(cherry picked from commit 3bcd04f528597dac0a7084865461574ab4a06465)

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

index f99613851a958adbd30a1ff2017959e618f05609..3f900e2b434f5fa7628ef740e6d6d642ff1e360e 100644 (file)
@@ -318,8 +318,11 @@ jQuery.event = {
 
                        // Native handler
                        handle = ontype && cur[ ontype ];
-                       if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
-                               event.preventDefault();
+                       if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
+                               event.result = handle.apply( cur, data );
+                               if ( event.result === false ) {
+                                       event.preventDefault();
+                               }
                        }
                }
                event.type = type;
index 1cc5501c6f743f2ccbcd7d470d79d234f0acedb4..d81551da94edb84e4128a546361f5377bb474d63 100644 (file)
@@ -2686,3 +2686,11 @@ test( "String.prototype.namespace does not cause trigger() to throw (#13360)", f
        equal( errored, false, "trigger() did not throw exception" );
        delete String.prototype.namespace;
 });
+
+test( "Inline event result is returned (#13993)", function() {
+       expect( 1 );
+
+       var result = jQuery("<p onclick='return 42'>hello</p>").triggerHandler("click");
+
+       equal( result, 42, "inline handler returned value" );
+});