Skip to content

Commit dcfccec

Browse files
authored
chore: remove boolean props defaultValue from metadata (#411)
1 parent e198fa5 commit dcfccec

File tree

7 files changed

+28
-21
lines changed

7 files changed

+28
-21
lines changed

packages/base/src/State.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class State {
3131
return this._data[prop];
3232
}
3333

34-
if (propData.type === "boolean" || propData.type === Boolean) {
34+
if (propData.type === Boolean) {
3535
return false;
3636
} else if (propData.multiple) { // eslint-disable-line
3737
return [];
@@ -135,14 +135,21 @@ class State {
135135
// Initialize properties
136136
const props = MetadataClass.getProperties();
137137
for (const propName in props) { // eslint-disable-line
138-
if (props[propName].type === "boolean") {
138+
139+
const propDefaultValue = props[propName].defaultValue;
140+
141+
if (props[propName].type === Boolean) {
139142
defaultState[propName] = false;
143+
144+
if (propDefaultValue !== undefined) {
145+
console.warn("The 'defaultValue' metadata key is ignored for all booleans properties, they would be initialized with 'false' by default"); // eslint-disable-line
146+
}
140147
} else if (props[propName].multiple) {
141148
defaultState[propName] = [];
142149
} else if (props[propName].type === Object) {
143150
defaultState[propName] = "defaultValue" in props[propName] ? props[propName].defaultValue : {};
144151
} else {
145-
defaultState[propName] = props[propName].defaultValue;
152+
defaultState[propName] = propDefaultValue;
146153
}
147154
}
148155

packages/main/src/CheckBox.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const metadata = {
3131
*/
3232
disabled: {
3333
type: Boolean,
34-
defaultValue: false,
3534
},
3635

3736
/**
@@ -46,7 +45,6 @@ const metadata = {
4645
*/
4746
readOnly: {
4847
type: Boolean,
49-
defaultValue: false,
5048
},
5149

5250
/**
@@ -62,7 +60,6 @@ const metadata = {
6260
*/
6361
checked: {
6462
type: Boolean,
65-
defaultValue: false,
6663
},
6764

6865
/**
@@ -102,7 +99,6 @@ const metadata = {
10299
*/
103100
wrap: {
104101
type: Boolean,
105-
defaultValue: false,
106102
},
107103

108104
/**

packages/main/src/DatePicker.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ const metadata = {
136136
},
137137

138138
_isPickerOpen: {
139-
defaultValue: false,
140139
type: Boolean,
141140
},
142141

packages/main/src/MessageStrip.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ const metadata = {
3030
* @defaultvalue "Information"
3131
* @public
3232
*/
33-
type: { type: MessageStripType, defaultValue: MessageStripType.Information },
33+
type: {
34+
type: MessageStripType,
35+
defaultValue: MessageStripType.Information,
36+
},
3437

3538
/**
3639
* Defines the icon to be displayed as graphical element within the <code>ui5-messagestrip</code>.
@@ -47,7 +50,10 @@ const metadata = {
4750
* @defaultvalue ""
4851
* @public
4952
*/
50-
icon: { type: URI, defaultValue: null },
53+
icon: {
54+
type: URI,
55+
defaultValue: null,
56+
},
5157

5258
/**
5359
* Defines whether the MessageStrip renders icon in the beginning.
@@ -56,7 +62,9 @@ const metadata = {
5662
* @defaultvalue false
5763
* @public
5864
*/
59-
hideIcon: { type: Boolean, defaultValue: false },
65+
hideIcon: {
66+
type: Boolean,
67+
},
6068

6169
/**
6270
* Defines whether the MessageStrip renders close icon.
@@ -65,9 +73,13 @@ const metadata = {
6573
* @defaultvalue false
6674
* @public
6775
*/
68-
hideCloseButton: { type: Boolean, defaultValue: false },
76+
hideCloseButton: {
77+
type: Boolean,
78+
},
6979

70-
_closeButton: { type: Object },
80+
_closeButton: {
81+
type: Object,
82+
},
7183
},
7284
events: /** @lends sap.ui.webcomponents.main.MessageStrip.prototype */ {
7385

packages/main/src/Select.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const metadata = {
5959
*/
6060
disabled: {
6161
type: Boolean,
62-
defaultValue: false,
6362
},
6463

6564
/**
@@ -82,12 +81,10 @@ const metadata = {
8281

8382
_opened: {
8483
type: Boolean,
85-
defaultValue: false,
8684
},
8785

8886
_focused: {
8987
type: Boolean,
90-
defaultValue: false,
9188
},
9289

9390
_fnClickSelectBox: {

packages/main/src/TableColumn.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ const metadata = {
8181

8282
_first: {
8383
type: Boolean,
84-
defaultValue: false,
8584
},
85+
8686
_last: {
8787
type: Boolean,
88-
defaultValue: false,
8988
},
9089
},
9190
};

packages/main/src/TextArea.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ const metadata = {
114114
*/
115115
showExceededText: {
116116
type: Boolean,
117-
defaultValue: false,
118117
},
119118

120119
/**
@@ -127,7 +126,6 @@ const metadata = {
127126
*/
128127
growing: {
129128
type: Boolean,
130-
defaultValue: false,
131129
},
132130

133131
/**
@@ -180,7 +178,6 @@ const metadata = {
180178
},
181179
_focussed: {
182180
type: Boolean,
183-
defaultValue: false,
184181
},
185182
_listeners: {
186183
type: Object,

0 commit comments

Comments
 (0)