# Changelog ## 1.2.0 ### Added All remaining CSS Color 4 color functions: `hwb()`, `lab()`, `lch()`, `oklab()`, `oklch()` and `color()` across all nine predefined spaces — `srgb`, `srgb-linear`, `display-p3`, `a98-rgb`, `prophoto-rgb`, `rec2020`, `xyz`, `xyz-d50` and `xyz-d65`. Colors outside sRGB are reduced by per-channel clipping, matching what browsers paint rather than the algorithm the specification asks for. See "Scope" in the README for why, and for the upstream issues. In the functions that already existed: the `none` keyword, bare numbers for saturation and lightness in modern syntax, CSS comments inside values, and form feed as whitespace. ### Fixed **`parseCSSColor("constructor")` and `parseCSSColor("__proto__")` threw a `TypeError`** instead of returning `null`. The keyword lookup walked the prototype chain, and those two survive lowercasing. Anything running this over untrusted strings — SVG attributes, user input — could be crashed by them. `hsl()` rounded down at exact half boundaries, so `hsl(180 100% 25%)` gave `[0, 127, 128]` where browsers give `[0, 128, 128]`. Whitespace is now trimmed by CSS's definition rather than JavaScript's, which strips more. A leading NBSP, `U+2028`, vertical tab or BOM made an otherwise valid color parse; browsers reject all four, and so does this now. ### Changed — inputs that used to parse and now return `null` Four forms were accepted that are not valid CSS, and every browser rejects them. If you feed the parser strings from a source that might produce these, check before upgrading: | input | was | now | | --- | --- | --- | | `rgb(5%, 50, 30)` | `[13, 50, 30, 1]` | `null` — legacy syntax may not mix percentages and numbers | | `rgb(50 50, 30)` | `[50, 50, 30, 1]` | `null` — separators may not be mixed | | `rgb(132 / 170 / 73 / 0.5)` | `[132, 170, 73, 0.5]` | `null` — a slash is not a component separator | | `rgb(132 170 73 0.5)` | `[132, 170, 73, 0.5]` | `null` — alpha must follow a slash | Alpha keeps the precision of the input. Chromium stores legacy colors as 8-bit RGBA, so it reports `rgb(1, 2, 3, 0.3)` as alpha `0.301961`; this library returns `0.3`. That is deliberate and unchanged from previous versions. ### Performance The scanner was rewritten to make a single pass over the input, without building intermediate strings, so parsing is substantially faster than 1.1.1 across every engine — most of all for `rgb()` and `hsl()`, which previously assembled their arguments a character at a time. ### Packaging Now ships an `exports` map alongside the existing `main`, `module` and `types` entries, so both `require()` and `import` resolve without changing anything for consumers on older bundlers. The MIT notice is attached to the built bundle, which previously shipped without it. ## 1.1.1 and earlier See the git history.