Skip to content

Commit d6d593b

Browse files
committed
Update generatePropertyDescriptors.mjs
1 parent 7d285c3 commit d6d593b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

scripts/generatePropertyDescriptors.mjs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,30 @@ const { dirname } = import.meta;
88
const list = fs
99
.readdirSync(path.resolve(dirname, "../lib/properties"))
1010
.map((file) => [file.replace(/\.js$/, ""), file]);
11-
const camelCasedProperties = new Map(list);
11+
const implementedProperties = new Map(list);
1212

1313
const requires = [];
1414
const descriptors = [];
15-
for (const [canonicalPropertyName, { styleDeclaration }] of propertyDefinitions) {
15+
for (const [canonicalPropertyName, { legacyAliasOf, styleDeclaration }] of propertyDefinitions) {
1616
const camel = dashedToCamelCase(canonicalPropertyName);
17-
if (camelCasedProperties.has(camel)) {
18-
requires.push(`const ${camel} = require("../properties/${camelCasedProperties.get(camel)}");`);
17+
const aliasCamel = legacyAliasOf ? dashedToCamelCase(legacyAliasOf) : "";
18+
if (implementedProperties.has(camel)) {
19+
requires.push(`const ${camel} = require("../properties/${implementedProperties.get(camel)}");`);
1920
for (const property of styleDeclaration) {
2021
descriptors.push(`"${property}": ${camel}.definition`);
2122
}
23+
} else if (implementedProperties.has(aliasCamel)) {
24+
for (const property of styleDeclaration) {
25+
descriptors.push(`"${property}": ${aliasCamel}.definition`);
26+
}
2227
} else {
2328
for (const property of styleDeclaration) {
2429
descriptors.push(`"${property}": getPropertyDescriptor("${canonicalPropertyName}")`);
2530
}
2631
}
2732
}
2833

29-
const outputFile = path.resolve(dirname, "../lib/generated/propertyDescriptors.js");
30-
31-
const dateToday = new Date();
32-
const [dateTodayFormatted] = dateToday.toISOString().split("T");
34+
const [dateTodayFormatted] = new Date().toISOString().split("T");
3335
const output = `"use strict";
3436
// autogenerated - ${dateTodayFormatted}
3537
@@ -41,4 +43,4 @@ module.exports = {
4143
};
4244
`;
4345

44-
fs.writeFileSync(outputFile, output);
46+
fs.writeFileSync(path.resolve(dirname, "../lib/generated/propertyDescriptors.js"), output);

0 commit comments

Comments
 (0)