mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Spinner: Fix value option initalization
This commit is contained in:
parent
1be2a79076
commit
299d5c88b8
@ -34,6 +34,7 @@
|
||||
|
||||
<div id="qunit-fixture">
|
||||
<input id="spin">
|
||||
<input id="spin2" value="2">
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
@ -12,7 +12,7 @@ var spinner_defaults = {
|
||||
numberformat: "n",
|
||||
page: 5,
|
||||
step: null,
|
||||
value: 0
|
||||
value: null
|
||||
};
|
||||
|
||||
commonWidgetTests('spinner', { defaults: spinner_defaults });
|
||||
|
@ -157,15 +157,30 @@ test("step", function() {
|
||||
|
||||
});
|
||||
|
||||
test("value", function() {
|
||||
expect(2);
|
||||
test("value, default, specified in markup", function() {
|
||||
var el = $('#spin2').spinner();
|
||||
equals(el.val(), 2, "starting value");
|
||||
});
|
||||
|
||||
el = $('#spin').spinner({ value: 100 });
|
||||
test("value, default, nothing specified", function() {
|
||||
var el = $('#spin').spinner();
|
||||
equals(el.val(), 0, "starting value");
|
||||
});
|
||||
|
||||
test("value, override", function() {
|
||||
var el = $('#spin').spinner({ value: 100 });
|
||||
equals(el.val(), 100, "starting value");
|
||||
});
|
||||
|
||||
test("value, override markup", function() {
|
||||
var el = $('#spin2').spinner({ value: 100 });
|
||||
equals(el.val(), 100, "starting value");
|
||||
});
|
||||
|
||||
test("value, override later", function() {
|
||||
var el = $('#spin').spinner();
|
||||
equals(el.val(), 0, "starting value");
|
||||
el.spinner('option', 'value', 1000);
|
||||
|
||||
equals(el.val(), 1000, "value option changed and set as current value");
|
||||
});
|
||||
|
||||
|
4
ui/jquery.ui.spinner.js
vendored
4
ui/jquery.ui.spinner.js
vendored
@ -29,11 +29,11 @@ $.widget('ui.spinner', {
|
||||
numberformat: "n",
|
||||
page: 5,
|
||||
step: null,
|
||||
value: 0
|
||||
value: null
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
this.value(this.element.val() || this.options.value);
|
||||
this.value(this.options.value !== null ? this.options.value : this.element.val());
|
||||
this._draw();
|
||||
this._mousewheel();
|
||||
this._aria();
|
||||
|
Loading…
Reference in New Issue
Block a user