Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/spec/ui/button-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("test/ui/button-spec", function () {
expect(aButton.label).toEqual("");
});
it("should have a default value", function () {
expect(aButton.label).toEqual("Button");
aButton.label = "";
expect(aButton.label).toEqual("");
aButton.label = void 0;
Expand All @@ -42,6 +43,12 @@ describe("test/ui/button-spec", function () {
aButton.draw();
expect(aButton.element.value).toEqual( "hello");
});

it("should has not default value when the Button is subclassed", function () {
var MyButton = Button.specialize();
aButton = new MyButton();
expect(aButton.label).toEqual("");
});
});
describe("draw", function () {
var aButton;
Expand Down
14 changes: 13 additions & 1 deletion ui/button.reel/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ var Button = exports.Button = Control.specialize(/** @lends module:"montage/ui/n
*/
label: {
get: function () {
return this._label;
return this._label !== void 0 && this._label !== null ?
this._label : this.defaultLabel;
},
set: function (value) {
if (typeof value !== "undefined" && this.converter) {
Expand Down Expand Up @@ -220,6 +221,17 @@ var Button = exports.Button = Control.specialize(/** @lends module:"montage/ui/n
}
},

constructor: {
value: function () {
this.super();

if (this.constructor !== Button) {
// no default value when the Button Component is subclassed
this.defaultLabel = "";
}
}
},

// HTMLInputElement/HTMLButtonElement methods
// click() deliberately omitted (it isn't available on <button> anyways)

Expand Down