Re: [css-houdini-drafts] [css-typed-om] Inputs for the CSSColorValue constructors (#1014)

> Indeed, you can solve all unnecessary error conditions by raising an error, but that doesn't make them good practice. It's far better to avoid creating the error condition in the first place.

We can make many more APIs avoid errors by severely restricting what they can do, that doesn't help authors either. There's a balance needed. Allowing authors more flexibility at the risk of allowing them to make mistakes is a common trade off.

> Please note that the TAG guidelines you link to (both of which I'm aware of and have even taught) do not apply here. 

The principles they represent do apply.

> They are both about optional arguments, which these are not. 

First, there *is* an optional argument to the CSS `rgb()` function that we seem to be forgetting about here, `a`.
Second, there's no reason to make all the arguments mandatory, `new CSSRGB({g:128})` could (and should) be equivalent to `new CSSRGB({r: 0, g: 128, b: 0, a: 1})`.

> Also, the first one is mainly about booleans, edited recently to generalize to all optional primitives. 

It used to be about booleans, and despite the anchor (which was left intact to not break links) now talks about the general case, which is why I included the link (and the links were for the benefit of other readers of the thread, I'm aware that you know them).

---

Back to Tab's original question, I'm now fairly well convinced that bare numbers passed into the constructor of a `CSSRGB` object (regardless of how they're passed) should be interpreted the same as bare numbers passed into CSS `rgb()`. This is an object model of the CSS `rgb()` function, it needs to match the semantics of the `rgb()` function. Full stop. I have no issue with convenience functions or conversions from other types that take 0-1 numbers, but will strongly object to redefining the semantics of the `rgb()` function in the object model. It should be all about modeling the `rgb()` function as it exists, not about creating a new general purpose color object (which I'm in favor of, and agree should use 0-1 numbers). Similarly, object models of other CSS color functions should accept the same arguments as their CSS equivalents.

-- 
GitHub Notification of comment by plinss
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/1014#issuecomment-744710271 using your GitHub account


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

Received on Monday, 14 December 2020 21:06:01 UTC