aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/event.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2013-02-26 12:19:04 -0500
committerDave Methvin <dave.methvin@gmail.com>2013-02-26 12:19:09 -0500
commit2bbc3d5860b81e128cd92f865673e10046caac7d (patch)
tree3816e3bf5e9e284e4f757cbc8856931ba516839e /test/unit/event.js
parent31478b90128a60585c087bee57d31148677a99cd (diff)
downloadjquery-2bbc3d5860b81e128cd92f865673e10046caac7d.tar.gz
jquery-2bbc3d5860b81e128cd92f865673e10046caac7d.zip
Fix #13471. $().on(".xyz"...) should avoid later crash.
If the event type is an empty string we end up hanging in .off() which makes for mighty hard debugging. Instead treat it as a no-op. Docs seem clear this is not allowed.
Diffstat (limited to 'test/unit/event.js')
-rw-r--r--test/unit/event.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index 6be4eb8e7..97c29ffef 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -555,6 +555,22 @@ test("bind(), multi-namespaced events", function() {
jQuery("#firstp").trigger("custom");
});
+test("namespace-only event binding is a no-op", function(){
+ expect(2);
+
+ jQuery("#firstp")
+ .on( ".whoops", function() {
+ ok( false, "called a namespace-only event" );
+ })
+ .on( "whoops", function() {
+ ok( true, "called whoops" );
+ })
+ .trigger("whoops") // 1
+ .off(".whoops")
+ .trigger("whoops") // 2
+ .off("whoops");
+});
+
test("bind(), with same function", function() {
expect(2);