Skip to content

v3.0.0

Compare
Choose a tag to compare
@danburzo danburzo released this 23 Feb 15:30
· 75 commits to main since this release

Breaking changes

This new release includes revamped color parsing to align with the latest css-color-4 spec. Regular expression matching has been replaced with a parser that follows the css-syntax spec more closely.

The new parser is more flexible with some aspects and stricter with others:

  • Trickier whitespace formulas around numbers, such as rgb(1-.2.3), are now properly handled (#187)
  • All non-legacy syntaxes allow mixing <number>, <percentage> and 'none' component values
  • The color() syntax no longer supports omitted component values that default to 0; it now requires exactly three component values. (#186)

Interpretation of component values has been aligned to the spec:

  • in non-legacy syntaxes, percentages are mapped to a reference range for that component. For example, the range of lch.c (Chroma in the CIELCh color space) is [0, 150], with 100% corresponding to 150.

Serialization has also been aligned to the spec:

  • lab and lch serialize the L component as <number>, not <percentage>
  • oklab‌, oklch and lrgb are serialized to oklab(), oklch(), and color(srgb-linear) respectively.

Please consult the migration guide for assistance in upgrading from 2.x to 3.0.

API changes

  • parseRgb and parseHsl now perform parsing of the modern syntax for rgb() and hsl() respectively;
  • parseRgbLegacy and parseHslLegacy have been added to parse the legacy syntaxes for rgb() / rgba() / hsl() / hsla()
  • parseOklab and parseOklch have been added to parse oklab() and oklch().