From f5163914fa1a751aa5bf10ce48c4b5307d65ed90 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 26 Feb 2013 12:19:04 -0500 Subject: 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. --- test/unit/event.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') 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); -- cgit v1.2.3