Bug Tracker

Ticket #13993 (closed bug: fixed)

Opened 2 years ago

Last modified 20 months ago

.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:
Blocking: Blocked by:

Description

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:
click1
undefined
click2
false

Should be:
click1
false
click2
false

Change History

comment:1 Changed 2 years ago by dmethvin

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

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 20 months ago by dmethvin

  • Owner set to dmethvin
  • Status changed from open to assigned

comment:3 Changed 20 months ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.