aboutsummaryrefslogtreecommitdiffstats
path: root/test
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:24:56 -0500
commitf5163914fa1a751aa5bf10ce48c4b5307d65ed90 (patch)
tree2610efe983970b947d0095e77f967d2e46b9aa29 /test
parentdabdea70eea81edc4ca32db8c269af3de90ff3f7 (diff)
downloadjquery-f5163914fa1a751aa5bf10ce48c4b5307d65ed90.tar.gz
jquery-f5163914fa1a751aa5bf10ce48c4b5307d65ed90.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')
-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 f08f5141e..d6b27fd6d 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);