w3c / css-houdini-drafts

Mirror of https://hg.css-houdini.org/drafts
https://drafts.css-houdini.org/
Other
1.84k stars 141 forks source link

[css-typed-om] type for hue angles #1033

Closed svgeesus closed 3 years ago

svgeesus commented 3 years ago

In 4.6 CSSColorValue objects, the type for hue angles is given as (for example, from HSL)

attribute CSSNumericValue h;

I would like to understand why CSSNumericValue was chosen, when there seems to be a more suitable angle type. I don't see the benefit of the flexibility to use other subtypes like time or flex here.

tabatkins commented 3 years ago

I think there may be some confusion - there is no more specific JS type. All values with units are unified in a single type, CSSUnitValue, with CSSNumericValue as the superclass that allows for math functions to be represented. Angles are just a CSSUnitValue with one of the angle unit values, or a CSSNumericValue whose CSS type resolves to one of those units.

For example, note that the transform functions work the same way - all the arguments are CSSNumericValue, and we just check on constructing/setting that they resolve to the correct CSS type depending on the value.

(Oh whoops, I see I left out the text that verifies the value type on setting the h attribute in CSSLCH; it's meant to look the same as CSSHSL.)