aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.menu.js
diff options
context:
space:
mode:
authorkborchers <kris.borchers@gmail.com>2012-07-09 23:37:27 -0500
committerkborchers <kris.borchers@gmail.com>2012-07-10 00:14:54 -0500
commit22d078aac608628323c687d1b7fe4424f47fd37f (patch)
treee30b17d071b1b23f4ed6f1284948eb9850e2535e /ui/jquery.ui.menu.js
parent019dcc26e307614681a6dfd0fcd9665548cb6ab6 (diff)
downloadjquery-ui-22d078aac608628323c687d1b7fe4424f47fd37f.tar.gz
jquery-ui-22d078aac608628323c687d1b7fe4424f47fd37f.zip
Menu: Move regular expression creation outside of the loops
Diffstat (limited to 'ui/jquery.ui.menu.js')
-rw-r--r--ui/jquery.ui.menu.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 3658bd8d5..4e565de45 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -173,7 +173,7 @@ $.widget( "ui.menu", {
},
_keydown: function( event ) {
- var match, prev, character, skip,
+ var match, prev, character, skip, regex,
preventDefault = true;
function escape( value ) {
@@ -228,9 +228,9 @@ $.widget( "ui.menu", {
character = prev + character;
}
+ regex = new RegExp( "^" + escape( character ), "i" );
match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
- return new RegExp( "^" + escape( character ), "i" )
- .test( $( this ).children( "a" ).text() );
+ return regex.test( $( this ).children( "a" ).text() );
});
match = skip && match.index( this.active.next() ) !== -1 ?
this.active.nextAll( ".ui-menu-item" ) :
@@ -240,9 +240,9 @@ $.widget( "ui.menu", {
// to move down the menu to the first item that starts with that character
if ( !match.length ) {
character = String.fromCharCode( event.keyCode );
+ regex = new RegExp( "^" + escape( character ), "i" );
match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
- return new RegExp( "^" + escape( character ), "i" )
- .test( $( this ).children( "a" ).text() );
+ return regex.test( $( this ).children( "a" ).text() );
});
}