From 3bcd04f528597dac0a7084865461574ab4a06465 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Thu, 19 Sep 2013 11:34:48 -0400 Subject: [PATCH] Fix #13993. Save result of native inline handlers. Close gh-1368. --- src/event.js | 7 +++++-- test/unit/event.js | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/event.js b/src/event.js index ea893067a..9efa50973 100644 --- a/src/event.js +++ b/src/event.js @@ -312,8 +312,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; diff --git a/test/unit/event.js b/test/unit/event.js index 11db61d1a..26f219195 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2613,3 +2613,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("

hello

").triggerHandler("click"); + + equal( result, 42, "inline handler returned value" ); +});