Repository navigation
Commit a93d53b
authored
* feat(css): lower nesting, and add `customMedia` / `rewriteDirSelector`
A target reading no CSS nesting was handed the nesting as written, so
the rules in it were never read. They are now written on their own, `&`
standing for the parent as `:is()` of it says — declined where the
target reads no `:is()` to write it with, where a declaration follows a
nested rule (hoisting it would let the rule win against a declaration
read after it), and for a rule written in an at-rule, which is what the
rules in it are read under.
`color-mix()` was named by `_UNREADABLE_COLOR_CALL_RE` but not by
`_FALLBACK_COLOR_FUNCTION_RE`, so a target reading none of it was left
with a declaration it drops and no fallback before it. A shorthand
lowered into longhands now carries the fallback against the longhand
naming the color rather than against the shorthand the target never
reads.
`customMedia` writes the query a `@custom-media` names wherever a
condition asks for it. `rewriteDirSelector` writes `:dir()` as the
`[dir]` attribute selector; both are off until asked for, the first
being a draft no browser ships unflagged and the second reading the
attribute rather than the direction an element may inherit.
* test(css): cover every branch the nesting scanners take
Codecov read 11 lines of the new code uncovered: the escape, quote and
bracket branches of the three selector scanners, and the guards around
them. Each is now driven by a selector that reaches it — a quoted space,
combinator or comma inside an attribute value, an escape written before
the `&`, a pseudo or attribute holding a combinator of its own, and the
part a dropped pseudo-element colon leaves empty.
Two guards were dead rather than uncovered and are gone: the rule asking
`_declarationsPrecedeRules` is one of the rules it reads, so that list is
never empty, and `_withColorFallback` is handed text it built from a
longhand and its value, so the name before the `:` is always there.
* fix(css): keep a rewritten nested rule, and group a custom media list
Two the review found, both confirmed against the code first.
A nested rule the prefixes rewrote was dropped whole: the caller handed
`_writeNested` no block for it, and the hoist then queued nothing and
answered null, so the rule went nowhere. It is several rules with
preludes of their own and no one rule to take out, so it stays where it
was written; the rules written in it still come out against it.
A `@custom-media` naming alternatives was written into a condition
whatever stood beside it, leaving an `and` binding to the last
alternative alone — `screen and (--m)` for `(a),(b)` says
`(screen and a) or b`. CSS has no parentheses to group a list inside a
condition, so one is now written only where the condition is the whole
prelude; a query of one condition is written wherever it is asked for.
* test(css): cover the paths that decline to lower through a real build
The nesting, custom-media and color-mix declines were reached only by the
unit tier, so a real build exercised one branch of each pair.
* feat(css): resolve `@custom-selector` under one option with `@custom-media`
The two are one draft and one build-time substitution, so the minimizer
takes one switch for both: `customMedia` becomes `resolveCustomAtRules`,
which now also writes what a `@custom-selector` name stands for.
A name is written as `:is(…)` whatever its list holds, matching what
`module.parser.css.customSelectors` already writes, so the same stylesheet
reads the same either way.
* chore: keep the changeset sentence under the length limit
* feat(css): put case folding and escape rewriting under options
Both rewrote a stylesheet with every option already off, so a caller
asking the printer to change nothing still got a changed sheet. Over the
repository's 619 stylesheets that closes 29 of the 42 that did not round
trip, leaving `!important` (a keyword the printer writes rather than
copies), a `data:` payload's percent escapes, and error recovery.
1 parent c04058e commit a93d53b
20 files changed
Lines changed: 1550 additions & 188 deletions
File tree
- .changeset
- declarations
- lib/css
- schemas
- test
- __snapshots__
- configCases/css
- minimize-lower-unsupported/__snapshots__
- minimize-nesting-lowered
- __snapshots__
- tooling
| 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 | |
|---|---|---|---|
| |||
2433 | 2433 | | |
2434 | 2434 | | |
2435 | 2435 | | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
2436 | 2441 | | |
2437 | 2442 | | |
2438 | 2443 | | |
| |||
2473 | 2478 | | |
2474 | 2479 | | |
2475 | 2480 | | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
2476 | 2486 | | |
2477 | 2487 | | |
2478 | 2488 | | |
2479 | 2489 | | |
2480 | 2490 | | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
2481 | 2501 | | |
2482 | 2502 | | |
2483 | 2503 | | |
| |||
0 commit comments