mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Spinner: Default min and max options to null.
This commit is contained in:
parent
c1cda180a9
commit
4387d19030
@ -149,22 +149,28 @@ test( "reading HTML5 attributes", function() {
|
||||
});
|
||||
|
||||
test( "ARIA attributes", function() {
|
||||
expect( 7 );
|
||||
expect( 9 );
|
||||
var element = $( "#spin" ).val( 2 ).spinner({ min: -5, max: 5 });
|
||||
|
||||
equal( element.attr( "role" ), "spinbutton", "role" );
|
||||
equal( element.attr( "aria-valuemin" ), -5, "aria-valuemin" );
|
||||
equal( element.attr( "aria-valuemax" ), 5, "aria-valuemax" );
|
||||
equal( element.attr( "aria-valuenow" ), 2, "aria-valuenow" );
|
||||
equal( element.attr( "aria-valuemin" ), "-5", "aria-valuemin" );
|
||||
equal( element.attr( "aria-valuemax" ), "5", "aria-valuemax" );
|
||||
equal( element.attr( "aria-valuenow" ), "2", "aria-valuenow" );
|
||||
|
||||
element.spinner( "stepUp" );
|
||||
|
||||
equal( element.attr( "aria-valuenow" ), 3, "stepUp 1 step changes aria-valuenow" );
|
||||
equal( element.attr( "aria-valuenow" ), "3", "stepUp 1 step changes aria-valuenow" );
|
||||
|
||||
element.spinner( "option", { min: -10, max: 10 } );
|
||||
|
||||
equal( element.attr( "aria-valuemin" ), -10, "min option changed aria-valuemin changes" );
|
||||
equal( element.attr( "aria-valuemax" ), 10, "max option changed aria-valuemax changes" );
|
||||
equal( element.attr( "aria-valuemin" ), "-10", "min option changed aria-valuemin changes" );
|
||||
equal( element.attr( "aria-valuemax" ), "10", "max option changed aria-valuemax changes" );
|
||||
|
||||
element.spinner( "option", "min", null );
|
||||
equal( element.attr( "aria-valuemin" ), undefined, "aria-valuemin not set when no min" );
|
||||
|
||||
element.spinner( "option", "max", null );
|
||||
equal( element.attr( "aria-valuemax" ), undefined, "aria-valuemax not set when no max" );
|
||||
});
|
||||
|
||||
test( "focus text field when pressing button", function() {
|
||||
|
@ -2,8 +2,8 @@ commonWidgetTests( "spinner", {
|
||||
defaults: {
|
||||
disabled: false,
|
||||
incremental: true,
|
||||
max: Number.MAX_VALUE,
|
||||
min: -Number.MAX_VALUE,
|
||||
max: null,
|
||||
min: null,
|
||||
numberFormat: null,
|
||||
page: 10,
|
||||
step: 1,
|
||||
|
8
ui/jquery.ui.spinner.js
vendored
8
ui/jquery.ui.spinner.js
vendored
@ -30,8 +30,8 @@ $.widget( "ui.spinner", {
|
||||
widgetEventPrefix: "spin",
|
||||
options: {
|
||||
incremental: true,
|
||||
max: Number.MAX_VALUE,
|
||||
min: -Number.MAX_VALUE,
|
||||
max: null,
|
||||
min: null,
|
||||
numberFormat: null,
|
||||
page: 10,
|
||||
step: 1,
|
||||
@ -247,11 +247,11 @@ $.widget( "ui.spinner", {
|
||||
_trimValue: function( value ) {
|
||||
var options = this.options;
|
||||
|
||||
if ( value > options.max) {
|
||||
if ( options.max != null && value > options.max) {
|
||||
return options.max;
|
||||
}
|
||||
|
||||
if ( value < options.min ) {
|
||||
if ( options.min != null && value < options.min ) {
|
||||
return options.min;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user