Skip to content

fix(swift): lower-case CSS-wide keywords and reject identifier-only shadows, as jsdom does - #159

Open
tmm wants to merge 1 commit into
mainfrom
swift-css-shadow
Open

tmm wants to merge 1 commit into
mainfrom
swift-css-shadow

Conversation

@tmm

@tmm tmm commented Nov 14, 2026

Copy link
Copy Markdown
Member

Description

Swift's inline style declaration kept a CSS-wide keyword's case for
properties that keep identifiers' case (font-family: INHERIT) or keep
values as written (the shadows), and kept a box-shadow or text-shadow
of nothing but identifiers (Foo, red, blue) as written. jsdom
lower-cases inherit, initial, unset, revert and revert-layer for
every property, reads none as a keyword, and rejects such a shadow, so
upstream's HTML and Swift's differed for those values.

normalizeCSSValue now does the same. CSSTests checks each property in
css/properties with the probes css.test.ts ran in jsdom, not only the
generated table, which is how the Rust port's runner found the
difference, and pins the keyword and shadow cases.

Test plan

Before

$ swift test --skip-build --filter ConformanceTests.CSSTests
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:57:5: Expectation failed: probe("font-family", "INHERIT") == "inherit"
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:58:5: Expectation failed: probe("box-shadow", "Unset") == "unset"
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:59:5: Expectation failed: probe("box-shadow", "NONE") == "none"
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:60:5: Expectation failed: probe("box-shadow", "Foo") == ""
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:61:5: Expectation failed: probe("text-shadow", "red, blue") == ""
✘ Test propertiesNormalizeAsJSDOM() recorded an issue at CSSTests.swift:48:7: Expectation failed: (probe(c.name, "Foo") == "Foo") == c.preserveCase
✘ Test propertiesNormalizeAsJSDOM() recorded an issue at CSSTests.swift:48:7: Expectation failed: (probe(c.name, "Foo") == "Foo") == c.preserveCase
✘ Test propertiesNormalizeAsJSDOM() recorded an issue at CSSTests.swift:48:7: Expectation failed: (probe(c.name, "Foo") == "Foo") == c.preserveCase
✘ Test run with 4 tests in 1 suite failed after 0.082 seconds with 8 issues.

After

$ swift test --skip-build --filter ConformanceTests.CSSTests
✔ Test cssWideKeywordsAndShadows() passed after 0.002 seconds.
✔ Test cssTextNormalizesAsJSDOM() passed after 0.007 seconds.
✔ Test propertyTableMatchesVectors() passed after 0.008 seconds.
✔ Test propertiesNormalizeAsJSDOM() passed after 0.104 seconds.
✔ Test run with 4 tests in 1 suite passed after 0.105 seconds.

$ swift test --skip-build --filter "ConformanceTests|LexicalTests|LexicalHTMLTests|LexicalSelectionTests|LexicalClipboardTests"
✔ Test run with 34 tests in 13 suites passed after 0.514 seconds.

The expected values were checked against jsdom
(element.style.setProperty(name, value) then getPropertyValue(name)).
Linux only; macOS and iOS run in CI.

…hadows, as jsdom does

## Description

Swift's inline style declaration kept a CSS-wide keyword's case for
properties that keep identifiers' case (`font-family: INHERIT`) or keep
values as written (the shadows), and kept a `box-shadow` or `text-shadow`
of nothing but identifiers (`Foo`, `red, blue`) as written. jsdom
lower-cases `inherit`, `initial`, `unset`, `revert` and `revert-layer` for
every property, reads `none` as a keyword, and rejects such a shadow, so
upstream's HTML and Swift's differed for those values.

`normalizeCSSValue` now does the same. `CSSTests` checks each property in
`css/properties` with the probes `css.test.ts` ran in jsdom, not only the
generated table, which is how the Rust port's runner found the
difference, and pins the keyword and shadow cases.

## Test plan

### Before

```
$ swift test --skip-build --filter ConformanceTests.CSSTests
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:57:5: Expectation failed: probe("font-family", "INHERIT") == "inherit"
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:58:5: Expectation failed: probe("box-shadow", "Unset") == "unset"
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:59:5: Expectation failed: probe("box-shadow", "NONE") == "none"
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:60:5: Expectation failed: probe("box-shadow", "Foo") == ""
✘ Test cssWideKeywordsAndShadows() recorded an issue at CSSTests.swift:61:5: Expectation failed: probe("text-shadow", "red, blue") == ""
✘ Test propertiesNormalizeAsJSDOM() recorded an issue at CSSTests.swift:48:7: Expectation failed: (probe(c.name, "Foo") == "Foo") == c.preserveCase
✘ Test propertiesNormalizeAsJSDOM() recorded an issue at CSSTests.swift:48:7: Expectation failed: (probe(c.name, "Foo") == "Foo") == c.preserveCase
✘ Test propertiesNormalizeAsJSDOM() recorded an issue at CSSTests.swift:48:7: Expectation failed: (probe(c.name, "Foo") == "Foo") == c.preserveCase
✘ Test run with 4 tests in 1 suite failed after 0.082 seconds with 8 issues.
```

### After

```
$ swift test --skip-build --filter ConformanceTests.CSSTests
✔ Test cssWideKeywordsAndShadows() passed after 0.002 seconds.
✔ Test cssTextNormalizesAsJSDOM() passed after 0.007 seconds.
✔ Test propertyTableMatchesVectors() passed after 0.008 seconds.
✔ Test propertiesNormalizeAsJSDOM() passed after 0.104 seconds.
✔ Test run with 4 tests in 1 suite passed after 0.105 seconds.

$ swift test --skip-build --filter "ConformanceTests|LexicalTests|LexicalHTMLTests|LexicalSelectionTests|LexicalClipboardTests"
✔ Test run with 34 tests in 13 suites passed after 0.514 seconds.
```

The expected values were checked against jsdom
(`element.style.setProperty(name, value)` then `getPropertyValue(name)`).
Linux only; macOS and iOS run in CI.

Amp-Thread-ID: https://ampcode.com/threads/T-506c8fa1-4309-40f1-9810-732b311eaeab
@tmm
tmm force-pushed the swift-css-shadow branch from 9f48b0b to d77175c Compare November 14, 2026 17:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants