]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Default min and max options to null.
authorScott González <scott.gonzalez@gmail.com>
Fri, 9 Sep 2011 23:24:10 +0000 (19:24 -0400)
committerScott González <scott.gonzalez@gmail.com>
Fri, 9 Sep 2011 23:24:10 +0000 (19:24 -0400)
tests/unit/spinner/spinner_core.js
tests/unit/spinner/spinner_defaults.js
ui/jquery.ui.spinner.js

index 57b6b3320fab1c05ab62fd9c3ca6996482b05b87..34a79bb16e95c5f3665bd4cc519ba278a55565c7 100644 (file)
@@ -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() {
index f155a658e997bc32fe5c3b26761c409bfe1d14ba..3321f87336cb856d46977ad58f44255e786486f4 100644 (file)
@@ -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,
index a5c25cd3403ef6df0da867c769b61e1297d4ec9e..97ee20e5455e9c23a7cf676eb8b23ea4439d5907 100644 (file)
@@ -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;
                }