Skip to content

Commit e9cdd57

Browse files
committed
Merge branch 'spinner-getCreateOptions'
Conflicts: ui/jquery.ui.spinner.js
2 parents e4898fd + e4c0f20 commit e9cdd57

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

tests/unit/spinner/spinner_defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ commonWidgetTests( "spinner", {
22
defaults: {
33
disabled: false,
44
incremental: true,
5-
max: null,
6-
min: null,
5+
max: Number.MAX_VALUE,
6+
min: -Number.MAX_VALUE,
77
numberFormat: null,
88
page: 10,
9-
step: null,
9+
step: 1,
1010
value: null,
1111

1212
// callbacks

ui/jquery.ui.spinner.js

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ $.widget( "ui.spinner", {
1919
widgetEventPrefix: "spin",
2020
options: {
2121
incremental: true,
22-
max: null,
23-
min: null,
22+
max: Number.MAX_VALUE,
23+
min: -Number.MAX_VALUE,
2424
numberFormat: null,
2525
page: 10,
26-
step: null,
26+
step: 1,
2727
value: null,
2828

2929
change: null,
@@ -33,31 +33,24 @@ $.widget( "ui.spinner", {
3333
},
3434

3535
_create: function() {
36-
this._markupOptions();
36+
this.value( this.options.value !== null ? this.options.value : this.element.val() || 0 );
3737
this._draw();
3838
this._mousewheel();
3939
this._aria();
4040
},
4141

42-
// TODO: should we use _getCreateOptions() now?
43-
// would increase overhead of init when options are specified,
44-
// but would move the defaults to the right location
45-
// and use our API the way it's meant to be used
46-
_markupOptions: function() {
47-
var that = this;
48-
$.each({
49-
min: -Number.MAX_VALUE,
50-
max: Number.MAX_VALUE,
51-
step: 1
52-
}, function( attr, defaultValue ) {
53-
if ( that.options[ attr ] === null ) {
54-
var value = that.element.attr( attr );
55-
that.options[ attr ] = typeof value === "string" && value.length > 0 ?
56-
that._parse( value ) :
57-
defaultValue;
42+
_getCreateOptions: function() {
43+
var options = {},
44+
element = this.element;
45+
46+
$.each( [ "min", "max", "step" ], function( i, option ) {
47+
var value = element.attr( option );
48+
if ( value !== undefined ) {
49+
options[ option ] = value;
5850
}
5951
});
60-
this.value( this.options.value !== null ? this.options.value : this.element.val() || 0 );
52+
53+
return options;
6154
},
6255

6356
_draw: function() {

0 commit comments

Comments
 (0)