Commit c17f589e authored by Rick Waldron's avatar Rick Waldron Committed by timmywil

Landing pull request 377. Check custom data != null(undefined), allows zero; Fixes #9285.

More Details:
 - https://github.com/jquery/jquery/pull/377
 - http://bugs.jquery.com/ticket/9285
parent a5cf257a
...@@ -345,7 +345,7 @@ jQuery.event = { ...@@ -345,7 +345,7 @@ jQuery.event = {
event.target = elem; event.target = elem;
// Clone any incoming data and prepend the event, creating the handler arg list // Clone any incoming data and prepend the event, creating the handler arg list
data = data ? jQuery.makeArray( data ) : []; data = data != null ? jQuery.makeArray( data ) : [];
data.unshift( event ); data.unshift( event );
var cur = elem, var cur = elem,
......
...@@ -14,6 +14,26 @@ test("null or undefined handler", function() { ...@@ -14,6 +14,26 @@ test("null or undefined handler", function() {
} catch (e) {} } catch (e) {}
}); });
test("bind(),live(),delegate() with non-null,defined data", function() {
expect(3);
var handler = function( event, data ) {
equal( data, 0, "non-null, defined data (zero) is correctly passed" );
};
jQuery("#foo").bind("foo", handler);
jQuery("#foo").live("foo", handler);
jQuery("div").delegate("#foo", "foo", handler);
jQuery("#foo").trigger("foo", 0);
jQuery("#foo").unbind("foo", handler);
jQuery("#foo").die("foo", handler);
jQuery("div").undelegate("#foo", "foo");
});
test("bind(), with data", function() { test("bind(), with data", function() {
expect(4); expect(4);
var handler = function(event) { var handler = function(event) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment