Skip to content

Commit d92611b

Browse files
fix: only make CSS and HTML transformations an engine cannot tell apart (#21774)
* fix(css): keep the newline that ended a bad string when minifying Only a newline makes a string bad, and the tokenizer leaves it unconsumed. The printer collapsed it like any other whitespace, so the string closed and a declaration the engine had thrown away came back — and where the token ran to the end of a rule the closing brace landed inside the string, leaving the rule open to swallow the stylesheet after it. Carried with the token, which is where the newline belongs whatever stands next to it. The three defects this filed against the CSSOM tier are gone. * fix(css): keep an `@property` descriptor's value as written `initial-value` is read against the `syntax` beside it, which webpack does not interpret — so `0px` there is not the `0` a length accepts, and the registered property came back with a different initial value. Opaque now, the way a custom property's own value already is. The wpt tier compared an SVG `<style>` as page text and never as CSS, so minifying one read as a change and the stylesheets inside SVG went unchecked. Both defects that filed are gone; the third is traced and re-filed with it. * fix(css): keep a clamped `calc()` and `attr()` spacing as written `font-style: oblique calc(100deg)` is clamped to the ±90deg bound CSS Fonts 4 §2.3 states, while the same angle written bare is rejected — and Chrome takes `oblique 100grad` off while reading `oblique 2rad` at face value, so a unit the range is not stated in loses the clamp too. Fold a math function to a bare term only where the property carries no clamp, or the term is inside it in the unit the clamp is stated in. `attr( name unit )` is dropped where `attr(name unit)` parses, so keep the space before the `)` rather than trimming it like any other. The two config-tier defects the equivalence suite had filed were the harness's, not the printer's: an escape is resolved before a name is matched, so `\2d-two` and `\2d\2d two` are one identifier, and a value the engine echoes rather than computes is compared under the one name the spec gives it — which is what the four filed `steps(N, jump-start)` and implied-last-stop values needed as well. * test(css): read a nested declaration block as the rule it sits in Declarations that follow a nested rule are their own `CSSNestedDeclarations` rule, which Chrome reports under the selector `&`. The equivalence harness took that at face value, so once an empty rule ahead of them was dropped and they became the parent's own, the same declarations read as a different rule under a shorter at-rule chain — the `css-cascade/scope-nesting.html` divergence. `&` alone is the rule it sits in, so a block labelled that way is now read under the enclosing style rule's own selector and chain. A reorder across a rule that prints something still diverges, which is what the two `minimize-nesting` cases hold: `.v` folds, `.w` keeps the block a rule of its own. * fix: keep `*:host` and a CR character reference as written Found by running the equivalence suite's DOM/CSSOM comparison over the whole 49,400-document wpt HTML corpus rather than the subset the committed tier reads. A featureless element matches no type or universal selector (CSS Scoping 1 §3.1), so the `*` a compound implies before `:host`, `:host()` or `:host-context()` is what keeps the rule from matching — dropping it brought `css/selectors/featureless-002` and `-003` to life. §13.2.3.5 rewrites a literal CR to LF before the tokenizer reads it, so a CR a character reference put in a text node has to stay one. The printer wrote it out raw, which re-parsed as a newline — `css/css-text/white-space`'s CR cases lost the character they test. * fix: four more transforms the wpt corpus caught changing meaning **An empty rule a `@namespace` after it is made inert by** stays. Only a rule the engine keeps ends the run a `@namespace` may stand in (CSS Namespaces 3 §3.1) — an unknown at-rule is thrown away and does not — so the guard closes on a qualified rule alone, which every engine keeps, and arms only for a source naming a `@namespace` at all. Dropping that rule carried the dead `@namespace` back to the head, where `attr(y|href)` started resolving. **A truncated escape** names U+FFFD (§4.3.7), and nothing at all inside a string (§4.3.5) — not the `\` the source shows, which escaped the `}` the printer closes the rule with, so `--foo: foo\` read back as `foo}`. **`flex-wrap: balance`** is in the grammar `mdn-data` states and in no engine, so merging it into `flex-flow` dropped the shorthand whole and took `flex-direction: column` with it. Measured over all 119 family slot keywords in headless Chromium: it is the only one the printer merges that Chrome rejects. **A mirrored `<selectedcontent>`** is content the engine makes, with no source behind it, so it is no longer mirrored while printing — serializing it wrote the selected option's subtree into the document, which the engine reading the output then mirrored a second time. * test(html): file the declarative shadow root the parser does not take out §13.2.6.4 makes a `<template>` carrying `shadowrootmode` its parent's shadow root and removes it from the tree, so an end tag after it reconstructs a formatting element around one child fewer. webpack models neither, because the tree it builds is also what it serializes — a template removed from the tree is a template missing from the output, so implementing this means separating the two, not adding a step. Filed against a fixture of its own rather than tracked only in a sweep: the browser tier reads `html/syntax`, `css/css-cascade` and `css/css-color`, and the one wpt document that shows this sits under `css/css-contain`, which is 810 documents to carry for one entry. The filing expires itself the run after the divergence goes. * fix(css): close a url token the input ran out of mid-escape Inside a custom property the value is written back as it stands, so a `url(` the input ended in kept no `)` — and the `}` the printer closes the rule with was read as part of the url, leaving `url(foo�}` where the engine has `url(foo�)`. Closed only where the escape ran out, which is the one shape Chrome writes back from the token's value rather than from its text: `url(foo` and `foo(bar` it echoes unclosed, and so does the printer. * fix(html): match an enumerated attribute's keyword without trimming it An enumerated attribute's value is an ASCII case-insensitive match for one of its keywords and nothing else — no whitespace is stripped — so `type="time "` names no keyword and leaves the input in its default `text` state. Trimming before the lookup made it a `time` input, which is a different control. Found by `html/semantics/forms/the-input-element/time.html`, whose fixture is `<input type="time "id="chkDefaultValue">`; case folding is unchanged, and the integer, URL and token-list attributes that do strip whitespace take their own branches. * fix(html): keep a style attribute's declarations after a `}` in it The attribute is minified inside a throwaway rule, which is what gives its declaration list the duplicate-drop and shorthand merges a block gets — but a `}` in the attribute closed that rule, and everything after it fell outside and was lost: `style="background:red;};background:limegreen"` painted red where the engine paints green. A style attribute is a declaration list, where such a `}` is part of a bad declaration and the declarations after it still apply. The value is now scanned first, and one holding a `}` outside every string, comment and bracket is left as written. A `}` inside a string or a balanced pair is not one, so `content: '}'` and `--custom: {a:b}` minify now where the old brace-free wrapper check declined them. * fix(html): keep the end tag a parser-implied element carried A `<td>` outside a row makes the parser imply a `<tr>`, and an implied element is printed transparently — but the `</tr>` closing it is the source's, and load-bearing: without it the whitespace after the row moves inside the row, and two text nodes become one. <table> <tr><td>a</td></tr> <td>b</td> </tr> </table> webpack's parse is right — it matches Chrome node for node — so only the serializer loses it. The implied case now asks `_canOmitEndTag`, which already refuses to drop an end tag a text or comment node follows. `html`, `head` and `body` keep their own `_canOmitShellEnd` path: routing them through this one materializes `</head></body></html>` on every document. * fix(html): decline a style attribute that leaves a construct open The sweep caught four documents the wrapper scan had regressed. A value ending inside an unclosed string, comment or bracket swallows the `}` the throwaway rule is closed with, so `background-image:url(foo` came back as `url(foo})` and `box-shadow:var(--t,10px` as `var(--t,10px})`. The old brace-free unwrap check had caught these by accident; the scan replacing it looked only for a `}` that closes the wrapper early. It now refuses both: a `}` outside every string, comment and bracket, and anything the value leaves open at its end — which the attribute's own end closes, and the wrapper's `}` does not. * refactor(html): name the throwaway rule a style attribute is minified inside The wrapper was written as a literal `a{` and read back with `slice(2, -1)`, so the two halves could drift apart and the `2` said nothing about where it came from. Named, and the read derived from the written length. The selector stays `a`: it is only ever written and read back here, it is the shortest one the printer cannot rewrite, and a value spelling the wrapper (`content:'a{color:red}'`, `--x:a{color:red}`) is read back as the value it is — the block is found by the print's own shape, not by searching the text for it. * fix(css): close a string a custom property's value ran out inside A custom property's value is written back as it stands, so a string the input ended in kept no closing quote and the `}` closing the rule was read as more of it: `--foo:"foo\` came back as `"foo};"` where the engine has `"foo"`. Closed alongside the url token the same slice already closes. All four `css-syntax/escaped-eof.html` stylesheets now read back the value the engine builds, checked in headless Chromium. * fix(css): read a lone `{}` block as a declaration's whole value §5.4.6 step 8 rejects a `{}` block in a non-custom declaration's value only when the value holds another non-whitespace token beside it; a block standing alone is the value. Both were rejected, so `color:{var(--x)}` was read as a nested rule — and a rule's `}` ends it, so the `;` after it went and the declaration behind it fused onto the block. Both were then lost: .a { color: rgb(2,2,2); color:{var(--x)}; background-color: rgb(1,1,1) } chrome reads color as rgb(0,0,0), webpack's output as rgb(2,2,2) <span style="font-family: {{ font }}; position: absolute; visibility: hidden"> position:absolute dropped The bail that stops a nested declaration's value at a top-level `{` now fires only once something stands before it, so a nested rule still costs one pass and `{}` alone is consumed and judged by step 8. Measured in headless Chromium: `.a{color:{a:b}}` is a declaration the grammar throws out, not a nested rule, and `.a{a:hover{color:red}}` is one. * test(css): hold the parser to the css-parsing-tests block contents The suite compiled every input and asserted only that nothing crashed — it never checked that the parser read the corpus the way the corpus says to. The 13 `blocks_contents.json` cases now assert the §5.4.5 production `parseABlocksContents` implements, which settles the one decision that has no other oracle: whether `<ident>:<value>` is a declaration or a qualified rule. They pass before and after the block-valued-declaration fix — the corpus holds no case where a `{}` block is a declaration's whole value, which is why nothing caught that clause. Its own coverage is in `CssSyntax.unittest.js`. `test/css-parsing-tests` and `test/html5lib-tests` join `test/wpt` and `test/test262-cases` in cspell's ignore list; a checked-out corpus otherwise fails the spellcheck on its own vocabulary. * test(css): retire the css-modules filing the merge fix already cleared Filed on `main` as "the comparison reads a dropped repeat as a reordering" — the adjacent-same-selector artifact. Reading a bare declaration block as the rule it sits in settled it, so the filing now fails the assertion that every filed defect still diverges, which is what takes it out. * fix(css): keep a color as written inside an interpolated gradient `linear-gradient(90deg in lch, red, lch(87.82 113.33 134.38 / 0))` had its stop rewritten to `#0f00`. The stops interpolate in the space the gradient names, and a color converted through sRGB maps back into that space as a different point — so the ramp between the stops is not the one the source paints. Verified by screenshot: the two differ before the fix and are pixel-identical after, across `in lch`, `in oklch`, an in-gamut stop and an out-of-gamut one. Only when the gradient states a space: without `in <space>` the stops interpolate in sRGB, where the rewrite is what the engine does anyway, so `linear-gradient(90deg, red, lch(…))` still folds and so does a color standing on its own. * test(css): compare what the engine echoes under the one spelling it has Four comparisons read a difference where the two values say the same thing: - An at-rule descriptor was compared verbatim, so `override-colors: 3 red` and the `3 rgb(255, 0, 0)` it was handed read as different rules. It now goes through the same normalization a declaration's value does, and `transparent` is folded to the `rgba(0, 0, 0, 0)` CSS Color 4 §5 defines it as. - A number was compared exactly, so a value derived from one the printer rounded — a matrix entry, a resolved font size — read as a change at the seventh digit. Numbers now compare within a relative 1e-5, which is under Chromium's 1/64px layout grid at every length a stylesheet uses and is the bound the printer's own rounding rests on. Everything that is not a number still has to match exactly, and the numbers have to line up one for one. - Two adjacent rules a printer joined were compared by adding their two separately computed lists together, so a `min()` or a percentage that resolves against the other's declarations came out differently on the two sides. The joined block is now resolved as the one block it is. - A zero length held as written — a `var()`-carrying value — was compared against the `0` the printer writes for it. * docs(css): bring six comments back in line with what the code does Each described the rule before this branch changed it: - consume-a-declaration step 8 quoted the spec line without the clause the code now implements ("and also contains any other non-whitespace token"). - `bailOnCurly` said it aborts on any top-level `{`; it aborts only on one something non-whitespace already stands before. - `A.source()` said "raw source slice"; an escape the input ran out of comes back as the character it names. - `_customPropertyToken` said every token is written as it stands; a url or a string the input ended inside is closed. - `_unwrapCalc` enumerated three shapes the parentheses cannot come off; a clamped range is a fourth. - `_escapeTextContent` and `mirrorSelectedContent` said nothing about the CR reference and the print-time skip. * fix(css): keep a gradient stop outside sRGB as written Measured in headless Chromium: a gradient's computed `background-image` reports the legacy sRGB forms as `rgb(…)` however they were spelled, and hands back a modern color-space function as written — linear-gradient(90deg, red, rgb(1,2,3)) -> rgb(255, 0, 0), rgb(1, 2, 3) linear-gradient(90deg, red, lch(50 20 30)) -> rgb(255, 0, 0), lch(50 20 30) so folding an `lch()` stop moves the value the CSSOM reports even where the stops interpolate in sRGB. The guard is now keyed on the color's space rather than on the gradient stating one, which also covers the ramp itself: with `in lch` the fold changed the painted pixels, in gamut as well as out. The harness gained the other half: a named color is the same color spelled a second way, so a bare identifier in a descriptor is now asked of the canvas like the hex and function forms already were. * fix(css): three rewrites that changed which declaration applies **Whitespace after an attribute selector's `|`.** The bar and the attribute name are one token sequence, so a space between them makes the selector invalid — `[| a]` is dropped where `[ |a]` is not. Collapsing it turned `[ | data-test-4] { color: red }` into a live rule and painted `selectors-attr-white-space-001` red where the source paints it green. **A `{}` block standing as a whole declaration value.** No grammar reads it, so the engine holds it as written like a custom property's value, and `color:{ [ var(--a)] }` came back respaced. **`initial` where the property's initial value is a length keyword.** `initial` is resolved before `zoom` scales a length, so `outline-width:initial` computes to 1.5px at `zoom:2` where `outline-width:medium` computes to 3px. The keywords are read off `<line-width>` and `<absolute-size>`, the two productions CSS states them in, rather than listed against the 15 properties that carry one. * fix(css): hold a container style query and `@function`'s result as written A container style query compares a custom property's value as the token stream it was written as, so squeezing a whitespace run inside one asks a different question. `@function`'s `result` is that same token stream — the one the call substitutes — so an empty one is a value, not a declaration to drop. The equivalence harness gains three things the corpus asked for: a rule's own declarations are read off the rule rather than off a probe Chrome cannot re-parse, a value's open blocks are closed at its end the way the tokenizer closes them, and a stylesheet is modelled one selector at a time so a printer moving a selector between two adjacent lists compares equal. * fix(html): two tree-construction steps the corpus caught A formatting end tag the list of active formatting elements cannot answer for is read as any other end tag rather than dropped (§13.2.6.4.7), so an element Noah's Ark unlisted — or one on the far side of the marker a `<select>` leaves behind — still closes. A `<template shadowrootmode>` is its parent's shadow root, which the engine takes out of the tree; webpack keeps it where it was written, so it is no longer a child the adoption agency may carry into the formatting element it reconstructs around the rest. It attaches only where `attachShadow()` would. * chore(css): sort the generated FEATURELESS_PSEUDO_CLASSES export into place * chore: add a changeset for the style-query and shadow-root fixes * refactor(html): move three name tables out of syntax.js into the generator `SHADOW_HOSTS`, `RESERVED_ELEMENT_NAMES` and `SHELL_ELEMENTS` are tables the minifier looks a name up in, so they belong in `tooling/generate-html-data.js` beside the rest of the parser vocabulary rather than next to the code reading them. Each carries the reason no dataset states it: two are spec prose the DOM and HTML name productions give, and the shell is the policy `OPTIONAL_END_TAG_FOLLOWERS` already documents leaving out. The heading names are named once and shared, so `HEADING` and `SHADOW_HOSTS` cannot drift apart. * fix(css): fold `text-align:initial` to the keyword it computes to `mdn-data` writes this property's initial as CSS 2.1 prose (`startOrNamelessValueIfLTRRightIfRTL`) rather than the keyword CSS Text 3 gives, so the name-shape test dropped it and the two bytes stayed. It is the one property of the 21 whose initial `mdn-data` states as prose that both names a fixed keyword and is shorter than `initial`: `text-size-adjust` and `-ms-content-zooming` read differently per user agent, and `all` has no initial at all. The keyword is supplemented and then judged by the same grammar, name-shape and length-keyword tests a derived one is, so the `zoom` rule that keeps `outline-width` out still applies; the generator throws once `mdn-data` states the keyword itself. Measured in headless Chromium under both `dir=ltr` and `dir=rtl`: `initial`, `start` and `unset` compute alike and paint the glyph at the same offset. * chore: fold the branch's changesets into one entry * fix(css): claim a style query's comments, and widen what names `@namespace` A container style query is written back from its source, comments included, so the copies the writer had queued have to be claimed there — flushed after the rule instead, the comment was emitted a second time. An at-keyword carrying an escape can still name `@namespace`, and only decoding tells the two apart, so the prologue scan now treats any escaped at-keyword as one. Over-wide on purpose: a false positive keeps an empty rule, which is the side that cannot change what the sheet means. The equivalence harness maps a surrogate escape to U+FFFD as §4.3.7 says, and normalizes a zero in every length unit CSS Values 4 states rather than the nine it named — the printer folds `0vw` too. * test: tighten the syntax-equivalence oracle Stop painting bare identifiers before comparing values: it made a named color and its hex spelling normalize to the same pixel, so an unsafe fold between the two compared equal. Compare integer pairs exactly and apply the numeric tolerance only to an element's own computed lengths, not to text, scripts or shadow content. * fix(css,html): keep descriptors opaque under streaming, decline a trailing escape A block that streams entered its rule outside the walk that set the `@property` / `@function` state, so `initial-value` and `result` were printed with ordinary value transforms once the block grew past the threshold. Carry the state per stream frame instead. A `style` attribute ending in an escape takes the wrapper rule's own `}` as an escaped brace, so it is declined rather than minified. Cover both, plus the escape and closed-pair arcs of the wrapper test, the non-minified text escapes and the two generator staleness guards. * test: read an escape a string runs out of the way the printer does §4.3.4 ignores a `\` at the end of a string, where an escape anywhere else names U+FFFD — the oracle named one on the as-written side only, which reads as a difference the printer never made. * test: consume a string's line continuation in the equivalence oracle §4.3.4 makes a `\` before a newline continue the line rather than name a character, so the pair is read as nothing instead of as the newline. * test: read a zero length's unit to its end in the oracle A unit runs on through `-`, an escape and any non-ASCII name character, so the trailing `\b` read `0rcap-foo` as `0rcap` and normalized it to the `0-foo` a different declaration writes. Keep the newline regexp above the JSDoc block it was splitting, which left `readEscape` untyped. * test: cover a foreign host and an unclosed comment An integration point runs HTML rules with a foreign current node, which is the one way a `<template shadowrootmode>` reaches a host `attachShadow` does not accept. A `style` value ending inside a comment would swallow the wrapper's own brace, so it is left as written. * test: give the shape helper a return type A recursive arrow has none to infer, so `tsc` reads it as implicitly any. * test: keep the text a dropped implied tag would lose Before `<body>` starts the insertion modes drop leading whitespace, so the tag has to be written back for the text node to survive re-parsing. * perf(css): reject a non-gradient function name before slicing it `_gradientName` allocated a substring for every function token, and the end-anchored regexp cannot reject early. Every gradient name ends in `gradient`, so one code point rejects 92.8% of them first — the same shape as the `_mayBeMathFunction` gate beside it. * fix(html): materialize an implied tag whose content opens outside it A start tag `inBody` ignores — `tr`, `td`, `th`, `tbody`, `thead`, `tfoot`, `caption`, `col`, `colgroup`, `frame` — still closes `<head>` on the way to "in body", so a head element written after one belongs to the body. Dropping the implied `<body>` handed it back to the head the modes had already left (§13.2.6.4.6), and a comment went further out still, to the element above. Both printer paths decide it the same way, the streamed one from the node rather than from the first piece emitted. * test(html): cover the comment branch of the implied-tag guard A comment leaves the body altogether — the modes put it in the element above — so it is its own case, not the head element's.
1 parent 94b4ed9 commit d92611b

55 files changed

Lines changed: 1900 additions & 248 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Only make CSS and HTML transformations an engine cannot tell apart.

‎.changeset/040-css-terminate-eof-tokens.md‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎cspell.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@
538538
"tooling/html-reflect.json",
539539
"test/test262-cases/**",
540540
"test/wpt/**",
541+
"test/css-parsing-tests/**",
542+
"test/html5lib-tests/**",
541543
"**/*.svg",
542544
"*.log",
543545
"**/*.wasm",

‎lib/css/data.js‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ const OMITTABLE_INITIAL_KEYWORDS = new Map([["grid-auto-flow", ["row", ["column"
682682
// makes the merge ambiguous, and `FAMILY_SLOT_CLASSES` names a type the printer
683683
// cannot classify as readily as one it can, so an unknown one declines.
684684
// prettier-ignore
685-
const FAMILY_SLOT_KEYWORDS = new Map([["border-bottom-width", ["medium","thick","thin"]], ["border-bottom-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-bottom-color", []], ["border-left-width", ["medium","thick","thin"]], ["border-left-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-left-color", []], ["border-right-width", ["medium","thick","thin"]], ["border-right-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-right-color", []], ["border-top-width", ["medium","thick","thin"]], ["border-top-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-top-color", []], ["column-rule-width", ["medium","thick","thin"]], ["column-rule-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["column-rule-color", []], ["flex-direction", ["column","column-reverse","row","row-reverse"]], ["flex-wrap", ["balance","nowrap","wrap","wrap-reverse"]], ["list-style-type", ["none"]], ["list-style-position", ["inside","outside"]], ["list-style-image", ["none"]], ["outline-width", ["medium","thick","thin"]], ["outline-style", ["auto","dashed","dotted","double","groove","inset","none","outset","ridge","solid"]], ["outline-color", ["auto"]], ["text-decoration-line", ["blink","grammar-error","line-through","none","overline","spelling-error","underline"]], ["text-decoration-style", ["dashed","dotted","double","solid","wavy"]], ["text-decoration-color", []], ["text-decoration-thickness", ["auto","from-font"]], ["text-emphasis-style", ["circle","dot","double-circle","filled","none","open","sesame","triangle"]], ["text-emphasis-color", []], ["text-wrap-mode", ["nowrap","wrap"]], ["text-wrap-style", ["auto","balance","pretty","stable"]]]);
685+
const FAMILY_SLOT_KEYWORDS = new Map([["border-bottom-width", ["medium","thick","thin"]], ["border-bottom-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-bottom-color", []], ["border-left-width", ["medium","thick","thin"]], ["border-left-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-left-color", []], ["border-right-width", ["medium","thick","thin"]], ["border-right-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-right-color", []], ["border-top-width", ["medium","thick","thin"]], ["border-top-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-top-color", []], ["column-rule-width", ["medium","thick","thin"]], ["column-rule-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["column-rule-color", []], ["flex-direction", ["column","column-reverse","row","row-reverse"]], ["flex-wrap", ["nowrap","wrap","wrap-reverse"]], ["list-style-type", ["none"]], ["list-style-position", ["inside","outside"]], ["list-style-image", ["none"]], ["outline-width", ["medium","thick","thin"]], ["outline-style", ["auto","dashed","dotted","double","groove","inset","none","outset","ridge","solid"]], ["outline-color", ["auto"]], ["text-decoration-line", ["blink","grammar-error","line-through","none","overline","spelling-error","underline"]], ["text-decoration-style", ["dashed","dotted","double","solid","wavy"]], ["text-decoration-color", []], ["text-decoration-thickness", ["auto","from-font"]], ["text-emphasis-style", ["circle","dot","double-circle","filled","none","open","sesame","triangle"]], ["text-emphasis-color", []], ["text-wrap-mode", ["nowrap","wrap"]], ["text-wrap-style", ["auto","balance","pretty","stable"]]]);
686686

687687
// prettier-ignore
688688
const FAMILY_SLOT_CLASSES = new Map([["border-bottom-width", ["length"]], ["border-bottom-style", []], ["border-bottom-color", ["color"]], ["border-left-width", ["length"]], ["border-left-style", []], ["border-left-color", ["color"]], ["border-right-width", ["length"]], ["border-right-style", []], ["border-right-color", ["color"]], ["border-top-width", ["length"]], ["border-top-style", []], ["border-top-color", ["color"]], ["column-rule-width", ["length"]], ["column-rule-style", []], ["column-rule-color", ["color"]], ["flex-direction", []], ["flex-wrap", []], ["list-style-type", ["custom-ident","string"]], ["list-style-position", []], ["list-style-image", ["image"]], ["outline-width", ["length"]], ["outline-style", []], ["outline-color", ["color"]], ["text-decoration-line", []], ["text-decoration-style", []], ["text-decoration-color", ["color"]], ["text-decoration-thickness", ["length","percentage"]], ["text-emphasis-style", ["string"]], ["text-emphasis-color", ["color"]], ["text-wrap-mode", []], ["text-wrap-style", []]]);
@@ -1637,13 +1637,9 @@ const INITIAL_VALUE_KEYWORDS = new Map([
16371637
["-ms-wrap-flow", "auto"],
16381638
["-ms-wrap-through", "wrap"],
16391639
["-webkit-border-after-style", "none"],
1640-
["-webkit-border-after-width", "medium"],
16411640
["-webkit-border-before-style", "none"],
1642-
["-webkit-border-before-width", "medium"],
16431641
["-webkit-border-end-style", "none"],
1644-
["-webkit-border-end-width", "medium"],
16451642
["-webkit-border-start-style", "none"],
1646-
["-webkit-border-start-width", "medium"],
16471643
["-webkit-line-clamp", "none"],
16481644
["-webkit-mask-attachment", "scroll"],
16491645
["-webkit-mask-clip", "border"],
@@ -1678,23 +1674,15 @@ const INITIAL_VALUE_KEYWORDS = new Map([
16781674
["baseline-source", "auto"],
16791675
["block-size", "auto"],
16801676
["border-block-end-style", "none"],
1681-
["border-block-end-width", "medium"],
16821677
["border-block-start-style", "none"],
1683-
["border-block-start-width", "medium"],
16841678
["border-bottom-style", "none"],
1685-
["border-bottom-width", "medium"],
16861679
["border-image-source", "none"],
16871680
["border-inline-end-style", "none"],
1688-
["border-inline-end-width", "medium"],
16891681
["border-inline-start-style", "none"],
1690-
["border-inline-start-width", "medium"],
16911682
["border-left-style", "none"],
1692-
["border-left-width", "medium"],
16931683
["border-right-style", "none"],
1694-
["border-right-width", "medium"],
16951684
["border-shape", "none"],
16961685
["border-top-style", "none"],
1697-
["border-top-width", "medium"],
16981686
["bottom", "auto"],
16991687
["box-decoration-break", "slice"],
17001688
["box-direction", "normal"],
@@ -1716,7 +1704,6 @@ const INITIAL_VALUE_KEYWORDS = new Map([
17161704
["column-gap", "normal"],
17171705
["column-height", "auto"],
17181706
["column-rule-style", "none"],
1719-
["column-rule-width", "medium"],
17201707
["column-span", "none"],
17211708
["column-width", "auto"],
17221709
["column-wrap", "auto"],
@@ -1756,7 +1743,6 @@ const INITIAL_VALUE_KEYWORDS = new Map([
17561743
["font-language-override", "normal"],
17571744
["font-optical-sizing", "auto"],
17581745
["font-palette", "normal"],
1759-
["font-size", "medium"],
17601746
["font-size-adjust", "none"],
17611747
["font-smooth", "auto"],
17621748
["font-stretch", "normal"],
@@ -1847,7 +1833,6 @@ const INITIAL_VALUE_KEYWORDS = new Map([
18471833
["offset-rotate", "auto"],
18481834
["outline-color", "auto"],
18491835
["outline-style", "none"],
1850-
["outline-width", "medium"],
18511836
["overflow-anchor", "auto"],
18521837
["overflow-block", "auto"],
18531838
["overflow-inline", "auto"],
@@ -1911,6 +1896,7 @@ const INITIAL_VALUE_KEYWORDS = new Map([
19111896
["stroke-linecap", "butt"],
19121897
["stroke-linejoin", "miter"],
19131898
["table-layout", "auto"],
1899+
["text-align", "start"],
19141900
["text-align-last", "auto"],
19151901
["text-anchor", "start"],
19161902
["text-autospace", "normal"],
@@ -2225,6 +2211,11 @@ const LEGACY_PSEUDO_ELEMENTS = new Set([
22252211
// combinator instead, and `|` makes the `*` a namespace's, not a redundant one.
22262212
const COMPOUND_CONTINUATIONS = new Set([":", ".", "#", "["]);
22272213

2214+
// The pseudo-classes selecting a featureless element, which matches no type or
2215+
// universal selector — so an implied `*` before one is what makes the selector
2216+
// match nothing, and dropping it would bring the rule to life.
2217+
const FEATURELESS_PSEUDO_CLASSES = new Set(["host", "host-context"]);
2218+
22282219
// The properties whose zero length keeps its unit: those whose own grammar
22292220
// offers a bare number beside the length, so the unit is what picks the
22302221
// reading, and the two an engine reads its own way.
@@ -2251,6 +2242,11 @@ const ZERO_UNIT_KEEPING_PROPERTIES = new Set([
22512242
// rather than folding to the value it equals.
22522243
const CALC_REJECTING_PROPERTIES = new Set(["overflow-clip-margin"]);
22532244

2245+
// The range a `calc()` is clamped to where the literal outside it is invalid,
2246+
// keyed by property: `[unit, min, max]`.
2247+
/** @type {Map<string, [string, number, number]>} */
2248+
const CLAMPED_VALUE_RANGES = new Map([["font-style", ["deg", -90, 90]]]);
2249+
22542250
// At-rules whose empty block is inert, so dropping it changes nothing.
22552251
const DROPPABLE_WHEN_EMPTY_AT_RULES = new Set([
22562252
"media",
@@ -7854,6 +7850,7 @@ module.exports.BOX_FAMILY_PREFIX = BOX_FAMILY_PREFIX;
78547850
module.exports.BOX_LONGHANDS = BOX_LONGHANDS;
78557851
module.exports.BOX_SHORTHANDS = BOX_SHORTHANDS;
78567852
module.exports.CALC_REJECTING_PROPERTIES = CALC_REJECTING_PROPERTIES;
7853+
module.exports.CLAMPED_VALUE_RANGES = CLAMPED_VALUE_RANGES;
78577854
module.exports.COLOR_ARGUMENT_FUNCTIONS = COLOR_ARGUMENT_FUNCTIONS;
78587855
module.exports.COLOR_KEYWORDS = COLOR_KEYWORDS;
78597856
module.exports.COLOR_NAME_TO_SHORTEST = COLOR_NAME_TO_SHORTEST;
@@ -7874,6 +7871,7 @@ module.exports.EIGHTH_TURN_TANGENT = EIGHTH_TURN_TANGENT;
78747871
module.exports.FAMILY_LONGHANDS = FAMILY_LONGHANDS;
78757872
module.exports.FAMILY_SLOT_CLASSES = FAMILY_SLOT_CLASSES;
78767873
module.exports.FAMILY_SLOT_KEYWORDS = FAMILY_SLOT_KEYWORDS;
7874+
module.exports.FEATURELESS_PSEUDO_CLASSES = FEATURELESS_PSEUDO_CLASSES;
78777875
module.exports.FILTER_FUNCTION_OMITTED = FILTER_FUNCTION_OMITTED;
78787876
module.exports.FLEX_KEYWORDS = FLEX_KEYWORDS;
78797877
module.exports.FONT_SIZE_KEYWORDS = FONT_SIZE_KEYWORDS;

0 commit comments

Comments
 (0)