Bug Tracker

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

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

Description (last modified by ajpiano)

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 (14)

comment:1 Changed 10 years ago by timmywil

Component: unfiledevent
Priority: undecidedlow

comment:2 Changed 10 years ago by john

Status: newopen

Let's get this in 1.7.

comment:3 Changed 9 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:4 Changed 9 years ago by Rick Waldron

Description: modified (diff)

+1, Seems like a bug, should be fixed

comment:5 Changed 9 years ago by jaubourg

+1, sounds like a bug to me

comment:6 Changed 9 years ago by timmywil


comment:7 Changed 9 years ago by dmethvin

Description: modified (diff)

+1, What could possibly go wrong?

comment:8 Changed 9 years ago by john

Description: modified (diff)


comment:9 Changed 9 years ago by scottgonzalez


comment:10 Changed 9 years ago by ajpiano

Description: modified (diff)


comment:11 Changed 9 years ago by dmethvin

Milestone: 1.next1.7
Owner: set to dmethvin
Priority: lowblocker
Status: openassigned

comment:12 Changed 9 years ago by Dave Methvin

Resolution: fixed
Status: assignedclosed

Fixes #8858. Pass the .trigger(..., data) to the event.special._default method.

Changeset: 0dc7b16e94ebb6ad27bcf8f12d62efac7d610db5

comment:13 Changed 9 years 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.

Note: See TracTickets for help on using tickets.