Opened 10 years ago
Closed 9 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: |
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 (3)
comment:1 Changed 10 years ago by
Component: | unfiled → event |
---|---|
Milestone: | None → 1.11/2.1 |
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 9 years ago by
Owner: | set to dmethvin |
---|---|
Status: | open → assigned |
comment:3 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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