Bug Tracker

Ticket #8858 (closed enhancement: fixed)

Opened 4 years ago

Last modified 3 years ago

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 4 years ago by timmywil

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

comment:2 Changed 4 years ago by john

  • Status changed from new to open

Let's get this in 1.7.

comment:3 Changed 3 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:4 Changed 3 years ago by rwaldron

  • Description modified (diff)

+1, Seems like a bug, should be fixed

comment:5 Changed 3 years ago by jaubourg

+1, sounds like a bug to me

comment:6 Changed 3 years ago by timmywil

+1,

comment:7 Changed 3 years ago by dmethvin

  • Description modified (diff)

+1, What could possibly go wrong?

comment:8 Changed 3 years ago by john

  • Description modified (diff)

+1

comment:9 Changed 3 years ago by scott.gonzalez

+1

comment:10 Changed 3 years ago by ajpiano

  • Description modified (diff)

+1

comment:11 Changed 3 years 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 3 years 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 3 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.

comment:14 Changed 3 years ago by dmethvin

Note: See TracTickets for help on using tickets.