[csswg-drafts] [css-color-4] Inconsistent results with `none` and interpolation color spaces. (#8563)

romainmenke has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-4] Inconsistent results with `none` and interpolation color spaces. ==
https://drafts.csswg.org/css-color-4/#interpolation

> Interpolation between [<color>](https://drafts.csswg.org/css-color-4/#typedef-color) values occurs by first converting them to a given color space which will be referred to as the interpolation color space below, and then linearly interpolating each component of the computed value of the color separately.

https://drafts.csswg.org/css-color-4/#interpolation-missing

> In the course of converting the two colors to the [interpolation color space](https://drafts.csswg.org/css-color-4/#interpolation-color-space), any [missing components](https://drafts.csswg.org/css-color-4/#missing-color-component) will be replaced with the value 0.

-----

This seems to lead to unexpected results as currently implemented in Safari and Chrome.

_In these examples I am using `color-mix` with the same color twice to illustrate to unexpected outcome. But the same is true with any combination of colors._

```css
color-mix(in hsl, hsl(90deg 100% none), hsl(90deg 100% 50%));
```

The source color space, interpolation color space and the color function happen to be the same.

The result is `hsl(90deg 100% 50%)`

------

```css
color-mix(in oklch, hsl(90deg 100% none), hsl(90deg 100% 50%));
```

The source color space, interpolation color space and the color function are **not** all the same.

The result is `oklch(0.445225 0.132279 135.943)` or roughly `hsl(92.45deg 100% 19%)`

But the hue angle and the lightness have changed, even when the inputs haven't changed and both inputs are the same.

------

```css
color-mix(in oklch, oklch(none 0.265 135.9), oklch(89% 0.265 135.9));
```

The source color space, interpolation color space and the color function happen to be the same.

The result is `oklch(0.89 0.265 135.9)` or roughly `hsl(89.91 100% 50%)`

------

Is this behavior intentional?

To me it is very surprising that you can unexpectedly hit or miss this special case where the color spaces and color functions align.

Keeping in mind that CSS authors might be using CSS variables, JavaScript, ... to dynamically combine and alter colors.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8563 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Saturday, 11 March 2023 16:28:34 UTC