r2458 - Progressbar: Modified value method to act as both a getter and setter. Fixed #4427 - pro...
Author: scott.gonzalez
Date: Wed Apr 15 18:57:56 2009
New Revision: 2458
Modified:
trunk/tests/unit/progressbar/progressbar_methods.js
trunk/ui/ui.progressbar.js
Log:
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.
Modified: trunk/tests/unit/progressbar/progressbar_methods.js
==============================================================================
--- trunk/tests/unit/progressbar/progressbar_methods.js (original)
+++ trunk/tests/unit/progressbar/progressbar_methods.js Wed Apr 15 18:57:56
2009
@@ -24,4 +24,13 @@
equals(actual, expected, 'destroy is chainable');
});
+test('value', function() {
+ expect(3);
+
+ var el = $('<div></div>').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);
Modified: trunk/ui/ui.progressbar.js
==============================================================================
--- trunk/ui/ui.progressbar.js (original)
+++ trunk/ui/ui.progressbar.js Wed Apr 15 18:57:56 2009
@@ -56,8 +56,12 @@
},
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) {