Skip to content

Commit 51564bb

Browse files
committed
Event: Empty namespaces should be uneventfully ignored
Thanks @hamishdickson for the report! Closes gh-1769 (cherry picked from commit 8653068)
1 parent 1ece10f commit 51564bb

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
@@ -14,7 +14,7 @@ var rformElems = /^(?:input|select|textarea)$/i,
1414
rkeyEvent = /^key/,
1515
rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
1616
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
17-
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
17+
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
1818

1919
function returnTrue() {
2020
return true;

test/unit/event.js

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

590+
test("Empty namespace is ignored", function(){
591+
expect( 1 );
592+
593+
jQuery("#firstp")
594+
.on( "meow.", function( e ) {
595+
equal( e.namespace, "", "triggered a namespace-less meow event" );
596+
})
597+
.trigger("meow.")
598+
.off("meow.");
599+
});
600+
590601
test("on(), with same function", function() {
591602
expect(2);
592603

0 commit comments

Comments
 (0)