Skip to content

Commit 329593c

Browse files
feat(react-property): build HTML props with boolean values (JSON)
These are React properties
1 parent f09374d commit 329593c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/react-property/scripts/build.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,27 @@ const attributeToProperty = {};
6464
*/
6565
const attributes = [];
6666

67+
/**
68+
* `autoFocus` is predefined and excluded from `HTMLDOMPropertyConfig.js`.
69+
*
70+
* @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/HTMLDOMPropertyConfig.js#L42
71+
* @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/DOMProperty.js#L206
72+
*/
73+
const booleanProperties = ['autoFocus'];
74+
6775
Object.keys(DOMProperty.getPossibleStandardName).forEach(attributeName => {
6876
const propertyName = DOMProperty.getPossibleStandardName[attributeName];
6977

7078
if (attributeName !== propertyName) {
7179
attributeToProperty[attributeName] = propertyName;
7280
}
7381

82+
const property = DOMProperty.properties[propertyName];
83+
84+
if (property && property.hasBooleanValue) {
85+
booleanProperties.push(propertyName);
86+
}
87+
7488
attributes.push(attributeName);
7589
});
7690

@@ -83,3 +97,8 @@ fs.writeFileSync(
8397
path.resolve(HTML_DIR, 'attribute-to-property.json'),
8498
JSON.stringify(attributeToProperty)
8599
);
100+
101+
fs.writeFileSync(
102+
path.resolve(HTML_DIR, 'boolean-properties.json'),
103+
JSON.stringify(booleanProperties)
104+
);

0 commit comments

Comments
 (0)