Skip to main content

Bug Tracker

Side navigation

#8858 closed enhancement (fixed)

Opened April 13, 2011 11:25AM UTC

Closed September 19, 2011 07:43PM UTC

Last modified October 27, 2011 08:06PM UTC

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

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) &&
Attachments (0)
Change History (14)

Changed April 15, 2011 05:01AM UTC by timmywil comment:1

component: unfiledevent
priority: undecidedlow

Changed April 17, 2011 12:47AM UTC by john comment:2

status: newopen

Let's get this in 1.7.

Changed May 22, 2011 07:27PM UTC by john comment:3

keywords: → 1.7-discuss

Nominating ticket for 1.7 discussion.

Changed May 22, 2011 09:28PM UTC by rwaldron comment:4

description: 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) && \ }}} \ 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) &&\ }}}\

+1, Seems like a bug, should be fixed

Changed May 23, 2011 12:38AM UTC by jaubourg comment:5

+1, sounds like a bug to me

Changed May 23, 2011 04:29AM UTC by timmywil comment:6

+1,

Changed May 24, 2011 09:33PM UTC by dmethvin comment:7

description: 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) &&\ }}}\ 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) && \ }}} \

+1, What could possibly go wrong?

Changed June 03, 2011 01:53PM UTC by john comment:8

description: 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) && \ }}} \ 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) &&\ }}}\

+1

Changed June 03, 2011 04:01PM UTC by scottgonzalez comment:9

+1

Changed June 05, 2011 09:29PM UTC by ajpiano comment:10

description: 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) &&\ }}}\ 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) && \ }}} \

+1

Changed July 12, 2011 03:04PM UTC by dmethvin comment:11

milestone: 1.next1.7
owner: → dmethvin
priority: lowblocker
status: openassigned

Changed September 19, 2011 07:43PM UTC by Dave Methvin comment:12

resolution: → fixed
status: assignedclosed

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

Changeset: 0dc7b16e94ebb6ad27bcf8f12d62efac7d610db5

Changed October 17, 2011 11:15AM UTC by mikael@karon.se comment:13

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.

Changed October 27, 2011 08:06PM UTC by dmethvin comment:14