Repository navigation
Commit 1c67141
authored
fix(css): keep minified CSS safe for older browsers and drop dead declarations (#22696)
* fix(css): read a box shorthand's printed sides where two of them touch
The print writes `.2em .4em` as `.2em.4em` and `0 -2px` as `0-2px`, but
lowering and folding split the value on spaces alone. Lowering `inset:.2em .4em`
for Chrome 80 wrote `top:.2em.4em` on every side, which the engine drops, and
`margin:.2em 0 .2em .4em;margin-right:2em` never folded. An `overflow` longhand
now folds into the shorthand too, where every target reads both keywords.
* fix(css): drop dead fallbacks and declarations a later same-selector rule overrides
- read a multi-value text-decoration where every target does, and drop the
-webkit-text-decoration twin beside it
- drop outline's currentcolor beside a non-auto style where every target
starts outline-color at CSS UI 4's auto
- take out of an earlier rule with the same selector, in the same scope, each
declaration a later rule writes again (not across a kept comment, a
rollback keyword, keyframes or distant merges)
- drop a hex fallback before an alpha hex every target reads
- fold a longhand list into a multi-layer transition/animation, one per layer
- background:transparent -> none; a centered top/bottom position -> keyword
- sort a type selector before its [attr] variants
* fix(css): name a centered edge only where every target reads the lone keyword
Presto took -o-transform-origin keywords only as a pair, so a position
written as percentages stays one unless the support data says otherwise.
* fix(css): keep minified CSS safe for older browsers
- with no browserslist, minify CSS for browserslist's defaults rather than
for every current engine, unless dropOverriddenDeclarations asks for that
- keep a shadow's currentcolor where Safari, iOS or WebKit Android is a target
- keep a flex value's parts where IE is a target
- write a :-webkit-any()/:-moz-any() copy only where each argument weighs
one class, as the vendor form does
- keep the space between touching tokens for engines older than custom
properties (IE, Presto, WebKit Android)
- part a fallback color from what follows it: #7f007f url(x), not one hash
* revert(css): drop a shadow's currentcolor for every target again
The WebKit gate rested on an MDN note no engine here could confirm.
* fix(css): minify a second time to the same output
- note every qualified rule for the same-selector drop, flat or not, and
read the earlier one as flat only when it is rewritten
- drop only after every copy in the piece is taken back
- leave a named layer's rules alone, as the gathered blocks are
- write background:transparent none as none too
* fix(css): leave unicode-range unspaced and read every one-class :is() argument
- an old engine's spacing skips a unicode-range value: U+131-140 is one range
- a non-ASCII or escaped class, and a comma inside an attribute's string,
no longer keep an :is() from its :-webkit-any()/:-moz-any() copy1 parent 3c95c6f commit 1c67141
16 files changed
Lines changed: 1001 additions & 85 deletions
File tree
- .changeset
- lib
- config
- css
- test
- configCases/css
- minify-chrome-100/__snapshots__
- minimize-convert-approximate-colors/__snapshots__
- minimize-corpus/__snapshots__
- minimize-rewrite-custom-properties/__snapshots__
- minimize-web-corpus/__snapshots__
- specCases
- unitCases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2627 | 2627 | | |
2628 | 2628 | | |
2629 | 2629 | | |
2630 | | - | |
| 2630 | + | |
| 2631 | + | |
2631 | 2632 | | |
2632 | 2633 | | |
2633 | | - | |
| 2634 | + | |
2634 | 2635 | | |
2635 | 2636 | | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
2636 | 2645 | | |
2637 | 2646 | | |
2638 | 2647 | | |
| |||
0 commit comments