});
test( "width", function() {
- expect( 5 );
+ expect( 6 );
var button,
element = $( "#speed" );
element.selectmenu();
button = element.selectmenu( "widget" );
+ equal( button[ 0 ].style.width, "", "no inline style" );
+
+ element.selectmenu( "option", "width", null );
equal( button.outerWidth(), element.outerWidth(), "button width auto" );
element.outerWidth( 100 );
element
.append( $( "<option>", { text: "Option with a little longer text" } ) )
- .selectmenu( "option", "width", "" )
+ .selectmenu( "option", "width", null )
.selectmenu( "refresh" );
equal( button.outerWidth(), element.outerWidth(), "button width with long option" );
element
.selectmenu( "destroy" )
.css( "width", "100%" )
- .selectmenu();
+ .selectmenu({ width: null });
button = element.selectmenu( "widget" );
equal( button.outerWidth(), 300, "button width fills container" );
});
at: "left bottom",
collision: "none"
},
- width: null,
+ width: false,
// callbacks
change: null,
this.buttonItem = this._renderButtonItem( item )
.appendTo( this.button );
- this._resizeButton();
+ if ( this.options.width !== false ) {
+ this._resizeButton();
+ }
this._on( this.button, this._buttonEvents );
this.button.one( "focusin", function() {
this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
)
);
- if ( !this.options.width ) {
+ if ( this.options.width === null ) {
this._resizeButton();
}
},
_resizeButton: function() {
var width = this.options.width;
- if ( !width ) {
+ // For `width: false`, just remove inline style and stop
+ if ( width === false ) {
+ this.button.css( "width", "" );
+ return;
+ }
+
+ // For `width: null`, match the width of the original element
+ if ( width === null ) {
width = this.element.show().outerWidth();
this.element.hide();
}