Bug Tracker

Opened 7 years ago

Closed 6 years ago

#6993 closed enhancement (fixed)

.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:


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;


Change History (5)

comment:1 Changed 7 years ago by davidflanagan

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.)

comment:2 Changed 6 years ago by snover

  • Milestone changed from 1.4.3 to 1.next
  • Priority set to low
  • Status changed from new to open
  • Type changed from bug to enhancement
  • Version changed from 1.4.2 to 1.4.3

comment:3 Changed 6 years ago by snover

  • Milestone changed from 1.4.4 to 1.5

Retarget all enhancements/features to next major version.

comment:4 Changed 6 years ago by john

  • Milestone set to 1.6
  • Owner set to john
  • Status changed from open to assigned

comment:5 Changed 6 years ago by John Resig

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

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

Changeset: 6e3b596514d20124260bc4b3febd8dc105420626

Note: See TracTickets for help on using tickets.