Repository navigation
Commit 69cc45e
authored
fix(css): read an rgb() separator grammar before folding it (#22251)
* fix(css): read an rgb()'s separator grammar before folding it
`_minifyColorFunction` cuts on whitespace, `,` and `/` in one pass without
recording which separator stood where, so every spelling collapsed to the
same argument list: `rgb(1, 2 3)`, `rgb(1 2, 3)`, `rgb(1 2 3, .5)`,
`rgb(1, 2, 3 / .5)`, `rgb(1 2 3 .5)` and `rgb(1 / 2 / 3)` all folded to a
color. Each is a declaration an engine drops, so folding it changed what
rendered.
This is the defect #22242 fixed for `hsl()`, `hwb()` and the Lab family,
left out of that change because `rgb()` reads its arguments through a
scanner of its own. The same two grammars decide it — the modern `A B C`
with an optional `/ D`, and the legacy `A, B, C` with an optional `, D`,
both of which `rgb()` has — so the check is the pair of regexps that change
already added, applied after the scan rather than before it, where only a
plausible color reaches it.
The pending changeset for #22242 covers this, so it is widened rather than
duplicated.
* chore(changeset): keep the color entry within the length limit
The union of the two color fixes ran to 148 characters, where
`.changeset/**` asks for one imperative sentence of 80 or fewer. Both
facts still fit: the unitless channels that now fold, and the separator
grammar that decides whether anything folds at all.
* test(javascript): assert what load() owes, not what Deno can import
`should install onto terser` asserted that under Deno `phases` is empty,
because Deno could not import terser's own sources when the test was
written. It sometimes can, and then the test fails — it went red once on
#22243, a pull request touching only CSS fixtures, and cost a re-run of a
21-minute job to establish it was not that change's doing.
Which sources a runtime reaches is the one thing `load` is written to
tolerate: it catches any failure and hands back terser's published entry
point. So the runtime is the wrong thing to assert. What `load` owes
everywhere is that it installed phases this build declares and nothing
else, and Node, which always reaches the sources, still owes the whole
set — both of which this now states.
The fallback path stays covered by behaviour rather than by a hardcoded
outcome: every `should mangle exactly as terser does` case compares
webpack's `minify` against terser's own, whichever way `load` resolved.1 parent 0813cba commit 69cc45e
6 files changed
Lines changed: 38 additions & 7 deletions
File tree
- .changeset
- lib/css
- test
- configCases/css/minimize-colors
- __snapshots__
- unitCases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7938 | 7938 | | |
7939 | 7939 | | |
7940 | 7940 | | |
| 7941 | + | |
| 7942 | + | |
| 7943 | + | |
| 7944 | + | |
| 7945 | + | |
| 7946 | + | |
| 7947 | + | |
| 7948 | + | |
7941 | 7949 | | |
7942 | 7950 | | |
7943 | 7951 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
136 | 146 | | |
137 | 147 | | |
138 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
96 | 101 | | |
97 | 102 | | |
98 | | - | |
99 | | - | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
0 commit comments