Skip to content

Commit

Permalink
Selectmenu: use guard clause for option length checking in refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
fnagel committed Apr 29, 2013
1 parent ee9c443 commit 17b6ff7
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions ui/jquery.ui.selectmenu.js
Expand Up @@ -163,22 +163,25 @@ $.widget( "ui.selectmenu", {


var item, var item,
options = this.element.find( "option" ); options = this.element.find( "option" );
if ( options.length ) {
this._readOptions( options ); if ( !options.length ) {
this._renderMenu( this.menu, this.items ); return;
}

this._readOptions( options );
this._renderMenu( this.menu, this.items );


this.menu.menu( "refresh" ); this.menu.menu( "refresh" );
this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" ).find( "a" ); 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 // Make sure menu is selected item aware
this.menu.menu( "focus", null, item ); this.menu.menu( "focus", null, item );
this._setAria( item.data( "ui-selectmenu-item" ) ); this._setAria( item.data( "ui-selectmenu-item" ) );


// Set disabled state // Set disabled state
this._setOption( "disabled", this._getCreateOptions().disabled ); this._setOption( "disabled", this._getCreateOptions().disabled );
}
}, },


open: function( event ) { open: function( event ) {
Expand Down

0 comments on commit 17b6ff7

Please sign in to comment.