Skip to main content

Bug Tracker

Side navigation

#6993 closed enhancement (fixed)

Opened September 02, 2010 11:50PM UTC

Closed April 17, 2011 12:39AM UTC

.bind() and .one() don't allow a function as data

Reported by: davidflanagan Owned by: john
Priority: low Milestone: 1.6
Component: event Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:
Description

The .bind() and .one() methods take two or three arguments, and have the signatures:

bind(type, data, handler)

bind(type, handler)

Currently, jQuery 1.4.2 distinguishes these cases with this code:

if ( jQuery.isFunction( data ) ) {

fn = data;

data = undefined;

}

This means that if you pass a function as the data argument, it will be treated as the handler argument and the handler will be ignored.

I propose that you change the code to instead test like this:

if (arguments.length === 2) {

fn = data;

data = undefined;

}

Attachments (0)
Change History (5)

Changed September 02, 2010 11:51PM UTC by davidflanagan comment:1

See line 2371 in jquery-1.4.2.js for the code referred to above. (It doesn't look right the way I pasted it into the ticket.)

Changed October 15, 2010 04:00AM UTC by snover comment:2

milestone: 1.4.31.next
priority: → low
status: newopen
type: bugenhancement
version: 1.4.21.4.3

Changed October 19, 2010 01:07AM UTC by snover comment:3

milestone: 1.4.41.5

Retarget all enhancements/features to next major version.

Changed April 17, 2011 12:37AM UTC by john comment:4

milestone: → 1.6
owner: → john
status: openassigned

Changed April 17, 2011 12:39AM UTC by John Resig comment:5

resolution: → fixed
status: assignedclosed

Allow function to be passed in as a data object to bind and one. Fixes #6993.

Changeset: 6e3b596514d20124260bc4b3febd8dc105420626