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 690d225
Browse filesBrowse the repository at this point in the historyBrowse files
fix(css): minify what a lowering reads and what it writes
Asked whether a lowered spelling is itself minified, two answers came back no:
- A media feature's own number was never shortened, lowered or not:
`@media (0480.0px <= width <= 768.50px)` kept every digit it was written with,
and the `min-`/`max-` pair lowered out of it kept them too. A feature is a
`<length>`, a `<ratio>` or an `<integer>` and nothing else, so the number in
one shortens like any other — where a prelude number elsewhere is An+B and
stripping a `+` there breaks the selector, which is what the guard was for. A
`style()` query still compares its tokens as written, and `@supports` reads a
declaration rather than a feature.
- A `text-decoration` whose color is a hex or a call was not lowered at all. The
print leaves out the separator between an ident and a hash — `solid #fff` is
`solid#fff`, two tokens whatever stands between them — and the lowering split
the printed value on its spaces, so the slots came back unreadable and the
rewrite declined. For Safari 15 that means the whole declaration is dropped
and the underline is lost, which is the failure the lowering exists to
prevent. It now splits at the junctions the print could have left bare, by the
same test the print makes; and a call that is a color rather than one that
takes one fills a color slot, out of `<color>`'s own grammar.
Everything else a lowering writes was already minified: the `inset` longhands
drop a zero's unit, the `text-decoration` ones shorten the color, the
`light-dark()` halves shorten theirs, the hex-alpha rewrite writes the shortest
alpha that quantizes back, and the `system-ui` stack drops its quotes.
"description": "Write a spelling the \`browserslist\` target cannot read as one it can — the same value said another way, rather than left for an engine that will drop it: a 4-/8-digit hex as \`rgba()\`, a double-position gradient stop as the two stops it names, \`inset\` / \`overflow\` / \`place-*\` as the longhands they set, \`text-decoration\` as its own longhands where a slot is newer than the shorthand, \`system-ui\` as the stack of platform font names it stands for, a \`:lang()\` or \`:not()\` holding a list as the \`:is()\` that means it, a media feature range as the \`min-\`/\`max-\` pair, and \`light-dark()\` as the custom-property pair a color scheme switches. On by default, and only in effect for a \`browserslist\` target — any other target names no browsers to answer for. Turning it off leaves every such spelling as written, which is what a stylesheet one of these rewrites gets wrong is minified with; it does not make the minifier write a spelling the target cannot read.",
"description": "Write a spelling the \`browserslist\` target cannot read as one it can — the same value said another way, rather than left for an engine that will drop it: a 4-/8-digit hex as \`rgba()\`, a double-position gradient stop as the two stops it names, \`inset\` / \`overflow\` / \`place-*\` as the longhands they set, \`text-decoration\` as its own longhands where a slot is newer than the shorthand, \`system-ui\` as the stack of platform font names it stands for, a \`:lang()\` or \`:not()\` holding a list as the \`:is()\` that means it, a media feature range as the \`min-\`/\`max-\` pair, and \`light-dark()\` as the custom-property pair a color scheme switches. On by default, and only in effect for a \`browserslist\` target — any other target names no browsers to answer for. Turning it off leaves every such spelling as written, which is what a stylesheet one of these rewrites gets wrong is minified with; it does not make the minifier write a spelling the target cannot read.",
"description": "Drop a rule or declaration nothing can read: a rule whose block ends up empty, a declaration an identical later one in the same block makes dead, and a rule an identical later sibling makes dead. On by default. Joining rules that are not dead is \`mergeRules\`.",
11825
+
"description": "Drop a rule or declaration nothing can read: a rule whose block ends up empty, a declaration a later one in the same block overrides, a rule an identical later sibling makes dead, and the \`@charset\` naming an encoding the output is not written in. On by default. Joining rules that are not dead is \`mergeRules\`.",
"description": "Drop a rule or declaration nothing can read: a rule whose block ends up empty, a declaration an identical later one in the same block makes dead, and a rule an identical later sibling makes dead. On by default. Joining rules that are not dead is \`mergeRules\`.",
11831
+
"description": "Drop a rule or declaration nothing can read: a rule whose block ends up empty, a declaration a later one in the same block overrides, a rule an identical later sibling makes dead, and the \`@charset\` naming an encoding the output is not written in. On by default. Joining rules that are not dead is \`mergeRules\`.",
"description": "Write a media feature in its range spelling where the target reads one (\`(min-width:100px)\` -> \`(width>=100px)\`), and collapse an \`and\` of two one-sided ranges into the interval it describes. On by default.",
11864
+
"description": "Shorten a rule's condition prelude: a media feature in its range spelling where the target reads one (\`(min-width:100px)\` -> \`(width>=100px)\`), an \`and\` of two one-sided ranges collapsed into the interval it describes, the \`all\` a query states before an \`and\` (which matches what the condition alone matches), and an operand a condition already states — in \`@supports\` and \`@container\` as well as \`@media\`. On by default.",
"description": "Write a media feature in its range spelling where the target reads one (\`(min-width:100px)\` -> \`(width>=100px)\`), and collapse an \`and\` of two one-sided ranges into the interval it describes. On by default.",
11870
+
"description": "Shorten a rule's condition prelude: a media feature in its range spelling where the target reads one (\`(min-width:100px)\` -> \`(width>=100px)\`), an \`and\` of two one-sided ranges collapsed into the interval it describes, the \`all\` a query states before an \`and\` (which matches what the condition alone matches), and an operand a condition already states — in \`@supports\` and \`@container\` as well as \`@media\`. On by default.",
Copy file name to clipboardExpand all lines: test/configCases/css/minimize-lower-unsupported/__snapshots__/ConfigCacheTest.snap
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ Array [
12
12
"/*! ...and \`hwb()\`, which shipped before the Lab family */.t10{background-color:#33b333;background-color:hwb(12020%30%)}",
13
13
"/*! a \`color()\`, which the target reads only as the sRGB it names */.t11{color:#6a805d;color:color(a98-rgb.44091.49971.37408)}",
14
14
"/*! \`system-ui\`, which the target reaches only by each platform's own name */.t12{font-family:system-ui,-apple-system,BlinkMacSystemFont,SegoeUI,Roboto,NotoSans,Ubuntu,Cantarell,HelveticaNeue}",
15
+
"/*! ...and the same where the print left out the separator before the color,
16
+
which is where the components are read back from */.t13a{text-decoration:underline;text-decoration-style:solid;text-decoration-color:#fff;text-decoration-thickness:2px}.t13b{text-decoration:underline;text-decoration-style:solid;text-decoration-color:#010203}.t13c{text-decoration:underline;text-decoration-style:solid;text-decoration-color:color-mix(inoklch,red,blue)}",
15
17
"/*! a \`text-decoration\` naming more than its line, written as longhands */.t13{text-decoration:underline;text-decoration-style:dotted;text-decoration-color:red;text-decoration-thickness:2px}",
16
18
"/*! a \`color-mix()\`, evaluated where every component is known */.t14{color:#706a43}",
17
19
"/*! a relative color, resolved against the origin it names */.t15{color:#669}",
Copy file name to clipboardExpand all lines: test/configCases/css/minimize-lower-unsupported/__snapshots__/ConfigTest.snap
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ Array [
12
12
"/*! ...and \`hwb()\`, which shipped before the Lab family */.t10{background-color:#33b333;background-color:hwb(12020%30%)}",
13
13
"/*! a \`color()\`, which the target reads only as the sRGB it names */.t11{color:#6a805d;color:color(a98-rgb.44091.49971.37408)}",
14
14
"/*! \`system-ui\`, which the target reaches only by each platform's own name */.t12{font-family:system-ui,-apple-system,BlinkMacSystemFont,SegoeUI,Roboto,NotoSans,Ubuntu,Cantarell,HelveticaNeue}",
15
+
"/*! ...and the same where the print left out the separator before the color,
16
+
which is where the components are read back from */.t13a{text-decoration:underline;text-decoration-style:solid;text-decoration-color:#fff;text-decoration-thickness:2px}.t13b{text-decoration:underline;text-decoration-style:solid;text-decoration-color:#010203}.t13c{text-decoration:underline;text-decoration-style:solid;text-decoration-color:color-mix(inoklch,red,blue)}",
15
17
"/*! a \`text-decoration\` naming more than its line, written as longhands */.t13{text-decoration:underline;text-decoration-style:dotted;text-decoration-color:red;text-decoration-thickness:2px}",
16
18
"/*! a \`color-mix()\`, evaluated where every component is known */.t14{color:#706a43}",
17
19
"/*! a relative color, resolved against the origin it names */.t15{color:#669}",
Copy file name to clipboardExpand all lines: test/configCases/css/minimize-values/__snapshots__/ConfigCacheTest.snap
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,9 @@ Array [
62
62
"/*! webpack: an operand a condition already states, whichever rule states it */@media (monochrome){.t47e{color:red}}@supports (display:grid){.t47f{color:red}}@supports ((display:grid) or (display:flex)){.t47g{color:red}}",
63
63
"/*! declined: a chain mixing the two operators is no flat list of either's, and
64
64
twoqueriesarenottwooperandsofanything*/@supports (display:grid) and (display:flex) or (display:table){.t47h{color:red}}@media (monochrome),(monochrome){.t47i{color:red}}",
65
+
"/*! webpack: a media feature is a length, a ratio or an integer and nothing
66
+
else, sothenumberinoneiswrittenthewayavalue's number is */@media (480px<=width<=768.5px){.t47j{color:red}}",
67
+
"/*! declined: a style query compares the tokens as they were written */@container style(--x: 0480.0px){.t47k{color:red}}",
65
68
"/*! webpack: a container query */@container card (width>400px){.t48{color:red}}",
66
69
"/*! webpack: an @supports condition */@supports (display:grid){.t49{color:red}}",
67
70
"/*! webpack: ...on a custom property */@supports (--x:1){.t50{color:red}}",
Copy file name to clipboardExpand all lines: test/configCases/css/minimize-values/__snapshots__/ConfigTest.snap
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,9 @@ Array [
62
62
"/*! webpack: an operand a condition already states, whichever rule states it */@media (monochrome){.t47e{color:red}}@supports (display:grid){.t47f{color:red}}@supports ((display:grid) or (display:flex)){.t47g{color:red}}",
63
63
"/*! declined: a chain mixing the two operators is no flat list of either's, and
64
64
twoqueriesarenottwooperandsofanything*/@supports (display:grid) and (display:flex) or (display:table){.t47h{color:red}}@media (monochrome),(monochrome){.t47i{color:red}}",
65
+
"/*! webpack: a media feature is a length, a ratio or an integer and nothing
66
+
else, sothenumberinoneiswrittenthewayavalue's number is */@media (480px<=width<=768.5px){.t47j{color:red}}",
67
+
"/*! declined: a style query compares the tokens as they were written */@container style(--x: 0480.0px){.t47k{color:red}}",
65
68
"/*! webpack: a container query */@container card (width>400px){.t48{color:red}}",
66
69
"/*! webpack: an @supports condition */@supports (display:grid){.t49{color:red}}",
67
70
"/*! webpack: ...on a custom property */@supports (--x:1){.t50{color:red}}",
0 commit comments