Skip to content
Permalink
Browse files

Spinner: Default min and max options to null.

  • Loading branch information...
scottgonzalez committed Sep 9, 2011
1 parent c1cda18 commit 4387d19030820077ac408e373bc135807e6a6002
Showing with 19 additions and 13 deletions.
  1. +13 −7 tests/unit/spinner/spinner_core.js
  2. +2 −2 tests/unit/spinner/spinner_defaults.js
  3. +4 −4 ui/jquery.ui.spinner.js
@@ -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,
@@ -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;
}

0 comments on commit 4387d19

Please sign in to comment.
You can’t perform that action at this time.