What happens if authors try to parse things like
"oklch(50% 10% var(--hue))
"oklch(50% 10% calc(0 + 20))
"color-mix(in oklab, currentColor, red)"
The Color API is not Typed OM, so the internal representation of the color needs to be concrete numbers.
However, it can still accept color strings that are not just a color space function with specific coords, and resolve them to numbers.
Each of these examples brings up different questions around this:
- Should the API provide some way to specify what the context is, so that variables and things like
currentColor or system colors are resolved? (an object literal, or even a DOM element)
- Should the API follow calculations in
calc() if they can be resolved?
- Should color functions like
color-mix() be accepted if they can be resolved?
And when a color is valid CSS, but not something the Color API can handle, what should happen? We throw an error or do something else?
What happens if authors try to parse things like
"oklch(50% 10% var(--hue))"oklch(50% 10% calc(0 + 20))"color-mix(in oklab, currentColor, red)"The Color API is not Typed OM, so the internal representation of the color needs to be concrete numbers.
However, it can still accept color strings that are not just a color space function with specific coords, and resolve them to numbers.
Each of these examples brings up different questions around this:
currentColoror system colors are resolved? (an object literal, or even a DOM element)calc()if they can be resolved?color-mix()be accepted if they can be resolved?And when a color is valid CSS, but not something the Color API can handle, what should happen? We throw an error or do something else?