@@ -173,7 +173,7 @@ $.widget( "ui.menu", {
173
173
} ,
174
174
175
175
_keydown : function ( event ) {
176
- var match , prev , character , skip ,
176
+ var match , prev , character , skip , regex ,
177
177
preventDefault = true ;
178
178
179
179
function escape ( value ) {
@@ -228,9 +228,9 @@ $.widget( "ui.menu", {
228
228
character = prev + character ;
229
229
}
230
230
231
+ regex = new RegExp ( "^" + escape ( character ) , "i" ) ;
231
232
match = this . activeMenu . children ( ".ui-menu-item" ) . filter ( function ( ) {
232
- return new RegExp ( "^" + escape ( character ) , "i" )
233
- . test ( $ ( this ) . children ( "a" ) . text ( ) ) ;
233
+ return regex . test ( $ ( this ) . children ( "a" ) . text ( ) ) ;
234
234
} ) ;
235
235
match = skip && match . index ( this . active . next ( ) ) !== - 1 ?
236
236
this . active . nextAll ( ".ui-menu-item" ) :
@@ -240,9 +240,9 @@ $.widget( "ui.menu", {
240
240
// to move down the menu to the first item that starts with that character
241
241
if ( ! match . length ) {
242
242
character = String . fromCharCode ( event . keyCode ) ;
243
+ regex = new RegExp ( "^" + escape ( character ) , "i" ) ;
243
244
match = this . activeMenu . children ( ".ui-menu-item" ) . filter ( function ( ) {
244
- return new RegExp ( "^" + escape ( character ) , "i" )
245
- . test ( $ ( this ) . children ( "a" ) . text ( ) ) ;
245
+ return regex . test ( $ ( this ) . children ( "a" ) . text ( ) ) ;
246
246
} ) ;
247
247
}
248
248
0 commit comments