Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #13993. Save result of native inline handlers. Close gh-1368.
  • Loading branch information
dmethvin committed Oct 6, 2013
1 parent 4375750 commit 3bcd04f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/event.js
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions test/unit/event.js
Expand Up @@ -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.