[css-houdini-drafts] [css-typed-om] Do we need separate classes per color space? (#1034)

LeaVerou has just created a new issue for https://github.com/w3c/css-houdini-drafts:

== [css-typed-om] Do we need separate classes per color space? ==
Given that the entire set of numeric types is represented by a single `CSSUnitValue` class, I was surprised to see the class hierarchy of `CSSColorValue`. Is this complexity and rigidity needed? Note that this requires adding new classes and new methods on every `CSSColorValue` for every single color space supported (and it makes it harder to support custom color spaces).

Why not just

```webidl
[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
interface CSSColorValue : CSSStyleValue {
 constructor(CSSKeywordish colorspace, sequence<CSSNumberish> coords, optional alpha);

 attribute CSSKeywordish colorspace;
 attribute sequence<CSSNumberish> coords;
 attribute CSSNumberish alpha;

    CSSColorValue to(CSSKeywordish colorspace);

    [Exposed=Window] static CSSColorValue parse(USVString cssText);
};
```

Though I'm not sure how to represent the difference between e.g. `color(srgb...)` and `rgb(...)`. Perhaps an additional `type` attribute.

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


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

Received on Wednesday, 12 May 2021 10:58:56 UTC