From: Scott González Date: Thu, 16 Apr 2009 01:57:56 +0000 (+0000) Subject: Progressbar: Modified value method to act as both a getter and setter. Fixed #4427... X-Git-Tag: 1.8a1~149 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=62f11b4a2ee8a8c10c51d614e37af1f0216385db;p=jquery-ui.git Progressbar: Modified value method to act as both a getter and setter. Fixed #4427 - progressbar('value') returns a reference to this instead of the value. --- diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/progressbar_methods.js index 9a162685b..a48fa3d47 100644 --- a/tests/unit/progressbar/progressbar_methods.js +++ b/tests/unit/progressbar/progressbar_methods.js @@ -24,4 +24,13 @@ test("destroy", function() { equals(actual, expected, 'destroy is chainable'); }); +test('value', function() { + expect(3); + + var el = $('
').progressbar({ value: 20 }); + equals(el.progressbar('value'), 20, 'correct value as getter'); + equals(el.progressbar('value', 30), el, 'chainable as setter'); + equals(el.progressbar('option', 'value'), 30, 'correct value after setter'); +}); + })(jQuery); diff --git a/ui/ui.progressbar.js b/ui/ui.progressbar.js index 6988f8dff..1cf077cae 100644 --- a/ui/ui.progressbar.js +++ b/ui/ui.progressbar.js @@ -56,8 +56,12 @@ $.widget("ui.progressbar", { }, value: function(newValue) { - arguments.length && this._setData("value", newValue); - return this._value(); + if (newValue === undefined) { + return this._value(); + } + + this._setData('value', newValue); + return this; }, _setData: function(key, value) {