Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 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 6 years ago by timmywil

  • Component changed from unfiled to event
  • Priority changed from undecided to low

comment:2 Changed 6 years ago by john

  • Status changed from new to open

Let's get this in 1.7.

comment:3 Changed 6 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:4 Changed 6 years ago by rwaldron

  • Description modified (diff)

+1, Seems like a bug, should be fixed

comment:5 Changed 6 years ago by jaubourg

+1, sounds like a bug to me

comment:6 Changed 6 years ago by timmywil


comment:7 Changed 6 years ago by dmethvin

  • Description modified (diff)

+1, What could possibly go wrong?

comment:8 Changed 6 years ago by john

  • Description modified (diff)


comment:9 Changed 6 years ago by scottgonzalez


comment:10 Changed 6 years ago by ajpiano

  • Description modified (diff)


comment:11 Changed 6 years ago by dmethvin

  • Milestone changed from 1.next to 1.7
  • Owner set to dmethvin
  • Priority changed from low to blocker
  • Status changed from open to assigned

comment:12 Changed 6 years ago by Dave Methvin

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Changeset: 0dc7b16e94ebb6ad27bcf8f12d62efac7d610db5

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