Skip to content

Commit 8653068

Browse files
committed
Event: Empty namespaces should be uneventfully ignored
Thanks @hamishdickson for the report! Closes gh-1769
1 parent b779831 commit 8653068

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var
1515
rkeyEvent = /^key/,
1616
rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
1717
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
18-
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
18+
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
1919

2020
function returnTrue() {
2121
return true;

test/unit/event.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,17 @@ test("namespace-only event binding is a no-op", function(){
583583
.off("whoops");
584584
});
585585

586+
test("Empty namespace is ignored", function(){
587+
expect( 1 );
588+
589+
jQuery("#firstp")
590+
.on( "meow.", function( e ) {
591+
equal( e.namespace, "", "triggered a namespace-less meow event" );
592+
})
593+
.trigger("meow.")
594+
.off("meow.");
595+
});
596+
586597
test("on(), with same function", function() {
587598
expect(2);
588599

0 commit comments

Comments
 (0)