Ticket #8858 (closed enhancement: fixed)
Special events - _default method doesn't have access to the `data` argument of the trigger method
| Reported by: | centi | Owned by: | dmethvin |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.7 |
| Component: | event | Version: | 1.5.2 |
| Keywords: | 1.7-discuss | Cc: | |
| Blocking: | Blocked by: |
Description (last modified by ajpiano) (diff)
The trigger method has an optional second argument data which is passed to all event handlers bound to the particular event which was triggered.
We can use special events, to define the behavior of our custom events, including a _default method. I would expect that this _default method will have access to the data argument, like the event handlers. But it doesn't.
jQuery source, line 2501:
if ( (!special._default || special._default.call( elem, event ) === false) &&
Suggested fix
if ( (!special._default || special._default.call( elem, event, data ) === false) &&
Change History
comment:1 Changed 2 years ago by timmywil
- Priority changed from undecided to low
- Component changed from unfiled to event
comment:3 Changed 2 years ago by john
- Keywords 1.7-discuss added
Nominating ticket for 1.7 discussion.
comment:4 Changed 2 years ago by rwaldron
- Description modified (diff)
+1, Seems like a bug, should be fixed
comment:7 Changed 2 years ago by dmethvin
- Description modified (diff)
+1, What could possibly go wrong?
comment:11 Changed 23 months ago by dmethvin
- Owner set to dmethvin
- Priority changed from low to blocker
- Status changed from open to assigned
- Milestone changed from 1.next to 1.7
comment:12 Changed 20 months ago by Dave Methvin
- Status changed from assigned to closed
- Resolution set to fixed
Fixes #8858. Pass the .trigger(..., data) to the event.special._default method.
Changeset: 0dc7b16e94ebb6ad27bcf8f12d62efac7d610db5
comment:13 Changed 20 months ago by mikael@…
Feels weird to me to have an alternative signature for the _default event vs. the regular ones. Submitted a patch @ https://github.com/jquery/jquery/pull/549 to fix this.
comment:14 Changed 19 months ago by dmethvin
Landed Mikael's better solution here: https://github.com/jquery/jquery/commit/df4a160be7fcc234a8e17eccb1c3fd02f231bcfc
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
