Skip to content

Commit 8d7cf57

Browse files
authored
fix: generate text-wrap-style: auto (#4321)
Fixes #4218 Turned out text-wrap-style got removed but supported alternative text-wrap: wrap was not generated instead. Now all should work. Also removed invalid text-wrap-mode: auto
1 parent 325eff1 commit 8d7cf57

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

packages/css-data/bin/mdn-data.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ const keywordValues = (() => {
366366
const result = { ...customData.keywordValues };
367367

368368
for (const property in filteredProperties) {
369+
const key = normalizePropertyName(property);
370+
// prevent merging with custom keywords
371+
if (result[key]) {
372+
continue;
373+
}
369374
const keywords = new Set<string>();
370375
walkSyntax(
371376
filteredProperties[property as keyof typeof filteredProperties].syntax,
@@ -390,7 +395,6 @@ const keywordValues = (() => {
390395
}
391396

392397
if (keywords.size !== 0) {
393-
const key = normalizePropertyName(property);
394398
result[key] = [...(result[key] ?? []), ...keywords];
395399
}
396400
}

packages/css-data/src/__generated__/keyword-values.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/css-data/src/custom-data.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,16 @@ keywordValues.listStyleType = [
8282
"georgian",
8383
"trad-chinese-informal",
8484
"kannada",
85+
"none",
86+
"initial",
87+
"inherit",
88+
"unset",
8589
];
8690

91+
// removed auto from keywords
92+
// fixed in webref btw
93+
keywordValues.textWrapMode = ["wrap", "nowrap", "initial", "inherit", "unset"];
94+
8795
export const customLonghandPropertyNames = [
8896
"boxShadowOffsetX",
8997
"boxShadowOffsetY",

packages/css-engine/src/core/merger.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ test("merge text-wrap-mode and text-wrap-style into text-wrap", () => {
272272
["white-space", "normal"],
273273
["text-wrap", "pretty"],
274274
]);
275+
expect(
276+
mergeKeywords([
277+
["text-wrap-mode", "wrap"],
278+
["text-wrap-style", "auto"],
279+
])
280+
).toEqual([
281+
["white-space", "normal"],
282+
["text-wrap", "wrap"],
283+
]);
284+
expect(mergeKeywords([["text-wrap-style", "auto"]])).toEqual([
285+
["text-wrap", "wrap"],
286+
]);
275287
});
276288

277289
test("merge text-wrap with vars", () => {

packages/css-engine/src/core/merger.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ const mergeWhiteSpaceAndTextWrap = (styleMap: StyleMap) => {
9494
if (collapse === "break-spaces") {
9595
styleMap.set("white-space", { type: "keyword", value: "break-spaces" });
9696
}
97+
if (style === "auto") {
98+
styleMap.set("text-wrap", modeValue ?? { type: "keyword", value: "wrap" });
99+
}
97100
if (style === "balance" || style === "stable" || style === "pretty") {
98101
styleMap.set("text-wrap", { type: "keyword", value: style });
99102
}

0 commit comments

Comments
 (0)