Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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.
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dmethvin
Author
Member
|
||
.off(".whoops") | ||
.trigger("whoops") // 2 | ||
.off("whoops"); | ||
}); | ||
|
||
test("bind(), with same function", function() { | ||
expect(2); | ||
|
||
.
missing?