You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 804e825
Browse filesBrowse the repository at this point in the historyBrowse files
feat(css): lower a spelling the browserslist target cannot read (#21926)
* feat(css): lower a spelling the browserslist target cannot read
The target's CSS abilities only ever held the printer back from reaching for
a newer spelling; one the author had already written was left as it was, even
where the selection says no target can read it. Each is now written the way
the target does read it: a hex alpha as its `rgba()`, a media range as the
`min-` / `max-` prefixes (an interval as the two bounds it names), `place-*` /
two-value `overflow` / `inset` as their longhands, a two-position color stop as
the two stops it names, and a multi-keyword `display` as the one keyword naming
the same box.
Each is refused where the longhands would not say what the shorthand does — a
substitution across a slot boundary, a keyword only some of the longhands take
— and a strict `>` / `<` media comparison is left alone, its negation being
Media Queries 4 as much as the range spelling it would replace.
* feat(css): write a fallback for a color the browserslist target cannot read
A `lab()` / `lch()` / `oklab()` / `oklch()` / `hwb()` color only converts to hex
where the two agree exactly, so a target reading none of those functions was
left with a declaration it drops. The color each names is now written as an
extra declaration before it — `color:#c65d06;color:oklch(59.686% .15619
49.7694)` — so the modern spelling still reaches the engines that read it while
the others get a color.
The two refusals the conversion makes are about replacing the function, not
standing before it: a fallback is only ever read where there is no better
answer, so it clips into the sRGB gamut and takes whichever byte rounding picks,
and writes an `rgba()` where the target has no hex alpha either.
Nothing is written where the author already set the property earlier in the
block, where the color holds a relative reference or a call this cannot fold, or
where the fallback would still name a function the target cannot read — the
engine drops such a fallback exactly as it drops the declaration it precedes.
`optimization.minimize.css.colorFallbacks` turns it off.
* Write a color the `browserslist` target cannot read as an extra declaration before the one naming it, in a spelling it does read: `color: oklch(59.686% 0.15619 49.7694)` is written as `color: #c65d06` and then the `oklch()` itself, so an engine reading neither the Lab family nor `hwb()` is left with a color rather than with nothing. The fallback is that color clipped into the sRGB gamut and rounded, which the declaration standing after it corrects wherever it is read. Nothing is written where the author already set the property earlier in the same block, where the color holds a substitution or a relative reference this cannot fold, or where the fallback would still name a function the target cannot read. On by default, and only in effect for a `browserslist` target — any other target names no browsers to answer for.
2418
+
* @since 5.111.0
2419
+
*/
2420
+
colorFallbacks?: boolean;
2416
2421
/**
2417
2422
* Which comments survive. `"some"`, the default, keeps a `/*!` banner and a comment annotated `@license` or `@preserve`; `true` (or `"all"`) keeps every comment and `false` keeps none; a string is read as a regular expression source, and it, a `RegExp` or a `(comment) => boolean` predicate is asked about each comment's own text and keeps the ones it accepts — standing in for the default rule rather than beside it, as terser's `format.comments` does, so a pattern that names nothing else drops the ones `"some"` would have kept. A `/*#` source-map pragma is a link rather than a comment, so `"some"` and `"all"` keep it; `false`, a pattern or a predicate decides it like any other. A predicate is handed to the minimizer's worker pool as source, so it must not close over anything.
0 commit comments