Skip to content

[css-color-4] Drop If H is missing, a = b = 0 in 9.6? #14530

Closed

Description

@romainmenke

See: https://drafts.csswg.org/css-color-4/#lch-to-lab

If H is missing, a = b = 0

I didn't implement this step and it seems that neither did colorjs, nor chrome

This was called out by @weinig in web-platform-tests/interop#1494


This seems inconsistent with hsl to srgb conversion where the result is a chromatic color.

rgb(from hsl(none 50 50) r g b)

becomes:

color(srgb 0.75 0.25 0.25)

It also means that the value doesn't round trip as nicely if you convert it back and forth between color spaces.


This also makes some interpolation impossible.

For example:

color-mix(in oklch, lch(80 30 270), lch(30 30 none))

Here an author might reasonably expect to have saturation that is consistent with 30 in lch.

e.g. oklch(0.61909628 0.08689075 264.1562336)

While instead it will be half that: oklch(0.61410188 0.04104694 264.1562336)


@svgeesus thoughts?

Activity

  1. romainmenke commented on Sep 30, 2026

    @romainmenke
    MemberAuthor

    Or maybe make this only apply when displaying a color, same as gamut mapping?
    In principle it makes sense that a color with a none hue displays as achromatic instead of whatever color happens to be 0deg.

    Making this a function of display means that interpolation, relative color, ... all still work as expected and preserve c.

  2. svgeesus commented on Sep 30, 2026

    @svgeesus
    Collaborator

    Making this a function of display means that interpolation, relative color, ... all still work as expected and preserve c.

    Yes, that seems reasonable. It also aligns the spec with implementations, without harm and with a benefit.

  3. self-assigned this
    on Sep 30, 2026
  4. svgeesus commented on Sep 30, 2026

    @svgeesus
    Collaborator

    So in the remaining pseudocode:

      <li>a = C cos(H)
      <li>b = C sin(H)

    what is the value of cos(none) and sin(none) ?

  5. romainmenke commented on Sep 30, 2026

    @romainmenke
    MemberAuthor

    On my end the none hue was already converted to 0 at this point as my implementation didn't record the missing hue beforehand.

    So cos(0) and sin(0).


    Aside: these cases with none and conversions from polar to rectangular and back always have a sharp edge somewhere. Really tricky to pick the right trade-offs :)

  6. svgeesus commented on Sep 30, 2026

    @svgeesus
    Collaborator

    Okay so oklch(60% 0.2 none) becomes oklab(60% 0.2 0) with all the chroma shoved into the a axis, giving a deep magenta.

    Which then round-trips to oklch(60% 0.2 0), preserving the chroma value it had before.

    Aside: these cases with none and conversions from polar to rectangular and back always have a sharp edge somewhere. Really tricky to pick the right trade-offs :)

    So very true.

  7. added
    Closed Accepted as Obvious Bugfix
    and removed on Sep 30, 2026
  8. added a commit that references this issue on Sep 30, 2026
    9c50d37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Closed Accepted as Obvious Bugfixcss-color-4

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Sponsor
    SponsoredKunjungi sekarang
    Promo