Side navigation
#11130 closed bug (fixed)
Opened January 05, 2012 02:44PM UTC
Closed January 13, 2012 01:36AM UTC
Last modified March 09, 2012 08:19PM UTC
jQuery.fn.on: binding map with null selector ignores data
Reported by: | zzzzbov | Owned by: | rwaldron |
---|---|---|---|
Priority: | low | Milestone: | 1.7.2 |
Component: | event | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Here's an example that will fail
var map, data; map = { 'foo': function (e) { //e.data will reportinstead of
console.log('data', e.data); } }; data = 'bar'; $(window).on(map, null, data).trigger('foo');
The problem exists on line null
on: function( types, selector, data, fn, /*INTERNAL*/ one ) { var origFn, type; // Types can be a map of types/handlers if ( typeof types === "object" ) { // ( types-Object, selector, data ) if ( typeof selector !== "string" ) { //3674 // ( types-Object, data ) data = selector; selector = undefined; }
It should probably read:
if ( typeof selector !== "string" && selector !== null ) {
Alternatively the docs need to be updated to address this difference:
http://api.jquery.com/on/#on-events-map-selector-data
**selector** A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element.
Should be changed to say:
If the selector is an empty string or omitted
Attachments (0)
Change History (4)
Changed January 05, 2012 02:47PM UTC by comment:1
Changed January 05, 2012 02:54PM UTC by comment:2
component: | unfiled → event |
---|---|
milestone: | None → 1.7.2 |
owner: | → rwaldron |
priority: | undecided → low |
status: | new → assigned |
Confirmed. I'll look into this now
I've created a jsFiddle for this issue:
http://jsfiddle.net/7M9cN/