Skip to content
Permalink
Browse files

Menu: Escape characters for RegExp matching for keyboard item matching.

  • Loading branch information...
jzaefferer committed Feb 22, 2011
1 parent 3557058 commit 68c13cd6a624b145ccf9a585baaea0aa36eff60c
Showing with 5 additions and 3 deletions.
  1. +5 −3 tests/visual/menu/flyoutmenu.js
@@ -57,15 +57,17 @@ $.widget("ui.flyoutmenu", {
} else {
character = prev + character;
}

function escape(value) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
var match = self.activeItem.parent("ul").children("li").filter(function() {
return new RegExp("^" + character, "i").test($("a", this).text());
return new RegExp("^" + escape(character), "i").test($("a", this).text());
});
var match = skip && match.index(self.active.next()) != -1 ? match.next() : match;
if (!match.length) {
character = String.fromCharCode(event.keyCode);
match = self.widget().children("li").filter(function() {
return new RegExp("^" + character, "i").test($(this).text());
return new RegExp("^" + escape(character), "i").test($(this).text());
});
}
if (match.length) {

0 comments on commit 68c13cd

Please sign in to comment.
You can’t perform that action at this time.