mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Spinner: Update button icons when option changes. Fixes #8926 - Spinner: Can't change icons option after init
This commit is contained in:
parent
0d4022bceb
commit
04d668b717
@ -5,10 +5,17 @@ module( "spinner: options" );
|
|||||||
// culture is tested after numberFormat, since it depends on numberFormat
|
// culture is tested after numberFormat, since it depends on numberFormat
|
||||||
|
|
||||||
test( "icons: default ", function() {
|
test( "icons: default ", function() {
|
||||||
expect( 2 );
|
expect( 4 );
|
||||||
var element = $( "#spin" ).val( 0 ).spinner().spinner( "widget" );
|
var element = $( "#spin" ).val( 0 ).spinner();
|
||||||
equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" );
|
equal( element.spinner( "widget" ).find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" );
|
||||||
equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" );
|
equal( element.spinner( "widget" ).find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" );
|
||||||
|
|
||||||
|
element.spinner( "option", "icons", {
|
||||||
|
up: "ui-icon-carat-1-n",
|
||||||
|
down: "ui-icon-carat-1-s"
|
||||||
|
});
|
||||||
|
equal( element.spinner( "widget" ).find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-carat-1-n" );
|
||||||
|
equal( element.spinner( "widget" ).find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-carat-1-s" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "icons: custom ", function() {
|
test( "icons: custom ", function() {
|
||||||
|
8
ui/jquery.ui.spinner.js
vendored
8
ui/jquery.ui.spinner.js
vendored
@ -368,6 +368,14 @@ $.widget( "ui.spinner", {
|
|||||||
value = this._parse( value );
|
value = this._parse( value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( key === "icons" ) {
|
||||||
|
this.buttons.first().find( ".ui-icon" )
|
||||||
|
.removeClass( this.options.icons.up )
|
||||||
|
.addClass( value.up );
|
||||||
|
this.buttons.last().find( ".ui-icon" )
|
||||||
|
.removeClass( this.options.icons.down )
|
||||||
|
.addClass( value.down );
|
||||||
|
}
|
||||||
|
|
||||||
this._super( key, value );
|
this._super( key, value );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user