]> source.dussan.org Git - jquery-ui.git/commitdiff
Selectmenu: use guard clause for option length checking in refresh
authorFelix Nagel <info@felixnagel.com>
Mon, 29 Apr 2013 20:23:11 +0000 (22:23 +0200)
committerFelix Nagel <info@felixnagel.com>
Mon, 29 Apr 2013 20:23:11 +0000 (22:23 +0200)
ui/jquery.ui.selectmenu.js

index 756a09f90da9a29916dd5ea93fd050d3894151c3..a4af2986e4473e0e5cc152ec2f0a0425aba52a40 100644 (file)
@@ -163,22 +163,25 @@ $.widget( "ui.selectmenu", {
 
                var item,
                        options = this.element.find( "option" );
-               if ( options.length ) {
-                       this._readOptions( options );
-                       this._renderMenu( this.menu, this.items );
+                       
+               if ( !options.length ) {
+                       return;
+               }
+               
+               this._readOptions( options );
+               this._renderMenu( this.menu, this.items );
 
-                       this.menu.menu( "refresh" );
-                       this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" ).find( "a" );
+               this.menu.menu( "refresh" );
+               this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" ).find( "a" );
 
-                       item = this._getSelectedItem();
+               item = this._getSelectedItem();
 
-                       // Make sure menu is selected item aware
-                       this.menu.menu( "focus", null, item );
-                       this._setAria( item.data( "ui-selectmenu-item" ) );
+               // Make sure menu is selected item aware
+               this.menu.menu( "focus", null, item );
+               this._setAria( item.data( "ui-selectmenu-item" ) );
 
-                       // Set disabled state
-                       this._setOption( "disabled", this._getCreateOptions().disabled );
-               }
+               // Set disabled state
+               this._setOption( "disabled", this._getCreateOptions().disabled );
        },
 
        open: function( event ) {