Skip to content
Permalink
Browse files

Fix #13993. Save result of native inline handlers. Close gh-1368.

  • Loading branch information
dmethvin committed Sep 19, 2013
1 parent 4375750 commit 3bcd04f528597dac0a7084865461574ab4a06465
Showing with 13 additions and 2 deletions.
  1. +5 −2 src/event.js
  2. +8 −0 test/unit/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;
@@ -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("<p onclick='return 42'>hello</p>").triggerHandler("click");

equal( result, 42, "inline handler returned value" );

This comment has been minimized.

Copy link
@mgol

mgol Oct 6, 2013

Member

@dmethvin If the test expects 42, it must be true! ;)

This comment has been minimized.

Copy link
@dmethvin

dmethvin Oct 6, 2013

Author Member

Even when it's the wrong answer, it's the right answer.

});

0 comments on commit 3bcd04f

Please sign in to comment.
You can’t perform that action at this time.