]> source.dussan.org Git - jquery.git/commitdiff
Event: Empty namespaces should be uneventfully ignored
authorDave Methvin <dave.methvin@gmail.com>
Wed, 10 Dec 2014 00:59:56 +0000 (19:59 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Wed, 10 Dec 2014 00:59:56 +0000 (19:59 -0500)
Thanks @hamishdickson for the report!

Closes gh-1769

src/event.js
test/unit/event.js

index 44961ef7de846f73160ca0e86c95ad5c6c4e2c26..0dd44e2449cd4abe48fc44827aa1ac4691f5b859 100644 (file)
@@ -15,7 +15,7 @@ var
        rkeyEvent = /^key/,
        rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
        rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
-       rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
+       rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
 
 function returnTrue() {
        return true;
index 7e2bc26b668b37927afeac810007a45b69d57829..8e33c6b9030c7753b43847196d351ee2db6cda9b 100644 (file)
@@ -583,6 +583,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);