Repository navigation
What's Changed
Features
- add
postcss-calc/reduce-tokens, which reduces a@csstools/css-tokenizer
token list and returns token replacements. It never reads token source
offsets, so it works on lists edited after tokenization.postcss-calc/reduce
shares its implementation; its output is unchanged except as noted under
Bug fixes.
Bug fixes
- A reduced value that would merge with a neighbouring token is now kept apart
by a space. For example,foo(calc(1px + 1px)b)becomesfoo(2px b)instead
offoo(2pxb), which reads as a different unit. This now also applies after
a+:a+calc(25% + 25%)withunwrapSingleValuebecomesa+ 50%instead
ofa+50%, which reads as a signed number. - A bare
clamp(),min(),max(),round()or other math function that
cannot be folded is no longer wrapped incalc(). For example,
clamp(1rem, 2.5vw, 2rem)stays as written instead of becoming
calc(clamp(1rem, 2.5vw, 2rem)). unwrapSingleValueno longer removescalc()from opaque values.
calc(var(--a)),calc(env(x))andcalc(attr(x px))keep theircalc(),
as the option only applies to fully resolved finite scalars.- Division by zero is no longer distributed over a sum with mixed units.
calc((2em - 2px) / 0)becomescalc(infinity * (2em - 2px))instead of a
sum that is alwaysNaN. - A literal
-0divisor keeps its sign:calc(1 / -0)now gives
calc(-infinity)instead ofcalc(infinity). reduceCalcand the plugin no longer report the nesting-limit error for a
value nested more than 1024 levels deep that has no supported math function
outsideurl(), a string or a comment, such asurl(calc(1+2))((((…. The
output is unchanged.
Changes
onParseErrorandonWarnare now called in source order, one candidate at
a time, instead of all parse errors first. A value with several errors may
report a different first error, for exampleclamp(.5/*c*/+!;)now reports
the+error at position 13 instead of the!. The output is unchanged.
Full Changelog: v11.2.3...v11.3.0