From 51564bbd39506d2076a5c82bdf87db92e81c26c9 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 9 Dec 2014 19:59:56 -0500 Subject: [PATCH] Event: Empty namespaces should be uneventfully ignored Thanks @hamishdickson for the report! Closes gh-1769 (cherry picked from commit 8653068dd6b8a515f5c1d8a0fda4479e9534103e) --- src/event.js | 2 +- test/unit/event.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/event.js b/src/event.js index ce8b71e30..f6674872d 100644 --- a/src/event.js +++ b/src/event.js @@ -14,7 +14,7 @@ var rformElems = /^(?:input|select|textarea)$/i, rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + rtypenamespace = /^([^.]*)(?:\.(.+)|)/; function returnTrue() { return true; diff --git a/test/unit/event.js b/test/unit/event.js index 61bdc7bca..c772ef44c 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -587,6 +587,17 @@ test("namespace-only event binding is a no-op", function(){ .off("whoops"); }); +test("Empty namespace is ignored", function(){ + expect( 1 ); + + jQuery("#firstp") + .on( "meow.", function( e ) { + equal( e.namespace, "", "triggered a namespace-less meow event" ); + }) + .trigger("meow.") + .off("meow."); +}); + test("on(), with same function", function() { expect(2); -- 2.39.5