Skip to content

Commit 924438d

Browse files
committed
css-color-parser: update contrast color notation
1 parent 8e02213 commit 924438d

4 files changed

Lines changed: 26 additions & 2 deletions

File tree

packages/css-color-parser/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes to CSS Color Parser
22

3+
### Unreleased (patch)
4+
5+
- Assign `rgb` color notation to `contrast-color()` (instead of `srgb`).
6+
37
### 4.1.2
48

59
_June 10, 2026_

packages/css-color-parser/dist/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/css-color-parser/src/functions/contrast-color.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function contrastColor(colorMixNode: FunctionNode, colorParser: ColorPars
3636
backgroundColorData.colorNotation = ColorNotation.sRGB;
3737

3838
const colorData: ColorData = {
39-
colorNotation: ColorNotation.sRGB,
39+
colorNotation: ColorNotation.RGB,
4040
channels: [0, 0, 0],
4141
alpha: 1,
4242
syntaxFlags: new Set([SyntaxFlag.ContrastColor, SyntaxFlag.Experimental]),

packages/css-color-parser/test/basic/contrast-color-function.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,23 @@ for (const test of tests) {
5858
);
5959
});
6060
}
61+
62+
assert.deepStrictEqual(
63+
color(parse('white')),
64+
{
65+
colorNotation: 'rgb',
66+
channels: [1, 1, 1],
67+
alpha: 1,
68+
syntaxFlags: new Set(['color-keyword', 'named-color']),
69+
},
70+
);
71+
72+
assert.deepStrictEqual(
73+
color(parse('contrast-color(black)')),
74+
{
75+
colorNotation: 'rgb',
76+
channels: [1, 1, 1],
77+
alpha: 1,
78+
syntaxFlags: new Set(['contrast-color', 'experimental']),
79+
},
80+
);

0 commit comments

Comments
 (0)