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: |
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;
}
Change History (5)
comment:1 Changed 7 years ago by
comment:2 Changed 7 years ago by
| Milestone: | 1.4.3 → 1.next |
|---|---|
| Priority: | → low |
| Status: | new → open |
| Type: | bug → enhancement |
| Version: | 1.4.2 → 1.4.3 |
comment:3 Changed 7 years ago by
| Milestone: | 1.4.4 → 1.5 |
|---|
Retarget all enhancements/features to next major version.
comment:4 Changed 6 years ago by
| Milestone: | → 1.6 |
|---|---|
| Owner: | set to john |
| Status: | open → assigned |
comment:5 Changed 6 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Allow function to be passed in as a data object to bind and one. Fixes #6993.
Changeset: 6e3b596514d20124260bc4b3febd8dc105420626

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