From 4387d19030820077ac408e373bc135807e6a6002 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 9 Sep 2011 19:24:10 -0400 Subject: [PATCH] Spinner: Default min and max options to null. --- tests/unit/spinner/spinner_core.js | 20 +++++++++++++------- tests/unit/spinner/spinner_defaults.js | 4 ++-- ui/jquery.ui.spinner.js | 8 ++++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js index 57b6b3320..34a79bb16 100644 --- a/tests/unit/spinner/spinner_core.js +++ b/tests/unit/spinner/spinner_core.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() { diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_defaults.js index f155a658e..3321f8733 100644 --- a/tests/unit/spinner/spinner_defaults.js +++ b/tests/unit/spinner/spinner_defaults.js @@ -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, diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index a5c25cd34..97ee20e54 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -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; } -- 2.39.5