Skip to content

Commit 7c7d3df

Browse files
committed
Spinner: Return formatted value when using value method.
1 parent a0eb042 commit 7c7d3df

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

ui/jquery.ui.spinner.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ function modifier( fn ) {
1717
return function() {
1818
var previous = this.options.value;
1919
fn.apply( this, arguments );
20-
this._format();
21-
this._aria();
20+
this._refresh();
2221
if ( previous !== this.options.value ) {
2322
this._trigger( "change" );
2423
}
@@ -48,7 +47,7 @@ $.widget( "ui.spinner", {
4847
this._value( this.options.value );
4948
this._draw();
5049
this._mousewheel();
51-
this._aria();
50+
this._refresh();
5251
},
5352

5453
_getCreateOptions: function() {
@@ -307,14 +306,6 @@ $.widget( "ui.spinner", {
307306
this._value( this._trimValue( this.options.value ) );
308307
}),
309308

310-
_aria: function() {
311-
this.element.attr({
312-
"aria-valuemin": this.options.min,
313-
"aria-valuemax": this.options.max,
314-
"aria-valuenow": this.options.value
315-
});
316-
},
317-
318309
_parse: function( val ) {
319310
if ( typeof val === "string" ) {
320311
val = $.global && this.options.numberFormat ? $.global.parseFloat( val ) : +val;
@@ -324,14 +315,23 @@ $.widget( "ui.spinner", {
324315

325316
_format: function() {
326317
var num = this.options.value;
327-
this.element.val( $.global && this.options.numberFormat ? $.global.format( num, this.options.numberFormat ) : num );
318+
return $.global && this.options.numberFormat ? $.global.format( num, this.options.numberFormat ) : num;
319+
},
320+
321+
_refresh: function() {
322+
this.element
323+
.val( this._format() )
324+
.attr({
325+
"aria-valuemin": this.options.min,
326+
"aria-valuemax": this.options.max,
327+
"aria-valuenow": this.options.value
328+
});
328329
},
329330

330331
// update the value without triggering change
331332
_value: function( value ) {
332333
this.options.value = this._trimValue( this._parse(value) );
333-
this._format();
334-
this._aria();
334+
this._refresh();
335335
},
336336

337337
destroy: function() {
@@ -371,7 +371,7 @@ $.widget( "ui.spinner", {
371371

372372
value: function( newVal ) {
373373
if ( !arguments.length ) {
374-
return this._parse( this.element.val() );
374+
return this._format();
375375
}
376376
this.option( "value", newVal );
377377
},

0 commit comments

Comments
 (0)