@@ -173,7 +173,7 @@ $.widget( "ui.menu", {
173173 } ,
174174
175175 _keydown : function ( event ) {
176- var match , prev , character , skip ,
176+ var match , prev , character , skip , regex ,
177177 preventDefault = true ;
178178
179179 function escape ( value ) {
@@ -228,9 +228,9 @@ $.widget( "ui.menu", {
228228 character = prev + character ;
229229 }
230230
231+ regex = new RegExp ( "^" + escape ( character ) , "i" ) ;
231232 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 ( ) ) ;
234234 } ) ;
235235 match = skip && match . index ( this . active . next ( ) ) !== - 1 ?
236236 this . active . nextAll ( ".ui-menu-item" ) :
@@ -240,9 +240,9 @@ $.widget( "ui.menu", {
240240 // to move down the menu to the first item that starts with that character
241241 if ( ! match . length ) {
242242 character = String . fromCharCode ( event . keyCode ) ;
243+ regex = new RegExp ( "^" + escape ( character ) , "i" ) ;
243244 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 ( ) ) ;
246246 } ) ;
247247 }
248248
0 commit comments