aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Waldron <waldron.rick@gmail.com>2011-05-16 10:38:36 -0400
committertimmywil <tim.willison@thisismedium.com>2011-05-16 10:38:36 -0400
commitc17f589ec99e8309e813a4081eed47f39a0c6120 (patch)
treef48065222582fed19528f11827c1da88022181e5
parenta5cf257a8a240f96f1ec255599fa1d1190f51ff5 (diff)
downloadjquery-c17f589ec99e8309e813a4081eed47f39a0c6120.tar.gz
jquery-c17f589ec99e8309e813a4081eed47f39a0c6120.zip
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
-rw-r--r--src/event.js2
-rw-r--r--test/unit/event.js20
2 files changed, 21 insertions, 1 deletions
diff --git a/src/event.js b/src/event.js
index 2bed09046..d2d57d676 100644
--- a/src/event.js
+++ b/src/event.js
@@ -345,7 +345,7 @@ jQuery.event = {
event.target = elem;
// 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 );
var cur = elem,
diff --git a/test/unit/event.js b/test/unit/event.js
index 13877e019..f71c7b29f 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -14,6 +14,26 @@ test("null or undefined handler", function() {
} 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() {
expect(4);
var handler = function(event) {