aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-02-26 11:32:12 -0500
committerjeresig <jeresig@gmail.com>2010-02-26 11:32:12 -0500
commit7f5179b65431b77e89fa32623a5000e3630c191c (patch)
tree7a90bfedfc97d6f31973178dd09d39925f63fe32 /test
parent28b489bfc8ad240b01e63ed93634f2b8770332a3 (diff)
downloadjquery-7f5179b65431b77e89fa32623a5000e3630c191c.tar.gz
jquery-7f5179b65431b77e89fa32623a5000e3630c191c.zip
Make sure that unbinding on a plain javascript object works correctly. Fixes #6184.
Diffstat (limited to 'test')
-rw-r--r--test/unit/event.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index cbde90eee..a220ebfc4 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -373,6 +373,35 @@ test("bind(), with different this object", function() {
ok( !jQuery.data(jQuery("#firstp")[0], "events"), "Event handler unbound when using different this object and data." );
});
+test("bind()/trigger()/unbind() on plain object", function() {
+ expect( 2 );
+
+ var obj = {};
+
+ // Make sure it doesn't complain when no events are found
+ jQuery(obj).trigger("test");
+
+ // Make sure it doesn't complain when no events are found
+ jQuery(obj).unbind("test");
+
+ jQuery(obj).bind("test", function(){
+ ok( true, "Custom event run." );
+ });
+
+ ok( jQuery(obj).data("events"), "Object has events bound." );
+
+ // Should trigger 1
+ jQuery(obj).trigger("test");
+
+ jQuery(obj).unbind("test");
+
+ // Should trigger 0
+ jQuery(obj).trigger("test");
+
+ // Make sure it doesn't complain when no events are found
+ jQuery(obj).unbind("test");
+});
+
test("unbind(type)", function() {
expect( 0 );