aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-09-09 19:24:10 -0400
committerScott González <scott.gonzalez@gmail.com>2011-09-09 19:24:10 -0400
commit4387d19030820077ac408e373bc135807e6a6002 (patch)
tree39052c49f5bb6583c4ec601e56483984fd78b640
parentc1cda180a93a6c0a63cf21a68dacb54233e03d03 (diff)
downloadjquery-ui-4387d19030820077ac408e373bc135807e6a6002.tar.gz
jquery-ui-4387d19030820077ac408e373bc135807e6a6002.zip
Spinner: Default min and max options to null.
-rw-r--r--tests/unit/spinner/spinner_core.js20
-rw-r--r--tests/unit/spinner/spinner_defaults.js4
-rw-r--r--ui/jquery.ui.spinner.js8
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;
}