Bug Tracker

Opened 4 years ago

Closed 3 years ago

#13993 closed bug (fixed)

.triggerHandler doesn't return value from handler for DOM0 events

Reported by: onovy Owned by: dmethvin
Priority: low Milestone: 1.11/2.1
Component: event Version: 1.10.1
Keywords: Cc:
Blocked by: Blocking:


According to documentation (http://api.jquery.com/triggerHandler/) .triggerHandler should return value returned by event handler:

Instead of returning the jQuery object (to allow chaining), .triggerHandler() returns whatever value was returned by the last handler it caused to be executed. If no handlers are triggered, it returns undefined.

But when you add event handler using DOM0 method (onXY attribute), .triggerHandler returns 'undefined' everytime. Doesn't matter what you return from handler function.

Tested in browsers: Chrome/Firefox
jQuery version: 1.10 / 1.10.1
Test case: http://jsbin.com/atofap/3/edit

In console is:

Should be:

Change History (3)

comment:1 Changed 4 years ago by dmethvin

  • Component changed from unfiled to event
  • Milestone changed from None to 1.11/2.1
  • Priority changed from undecided to low
  • Status changed from new to open

We've never fully supported inline handers but this looks easy enough to fix. https://github.com/jquery/jquery/blob/8643ac77fbd7508651639a41eced5338c1738c12/src/event.js#L300

comment:2 Changed 4 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from open to assigned
Note: See TracTickets for help on using tickets.