Re: [csswg-drafts] [css-values] Type conversion functions (#6408)

`control-value()` doesn't need type conversion, it just needs type *awareness*. Each control already has a well-defined type, and there's no good use-case for interpreting it *differently* than that, except to get it as a number vs percentage (in meter/progress/range), or as a string instead of a more specific value. (And every input knows how to produce a string (many can *only* produce strings), so you need the choice between the two.)

In the more general case, stringifying is already handled by the `string()` proposal (and its partner, `ident()`). Converting between a number and a percentage requires more context than just a value (it needs the range, or if it's the trivial 0-1 = 0%-100% range, you can just do it yourself with a trivial `calc()`; it's quite easy with `calc()` in all cases, actually).

The only thing that's left is the possibility of parsing a string into another value, like `attr()` can do. But are there use-cases for passing a CSS string value around like this *other than* getting an attribute's value? I don't think there is; at least, none have been presented in this issue, and I can't come up with any myself.

(As noted, CSS counters are *not* an example of this, because you don't actually want to parse the produced string as a number; the string can represent the value in any number of ways due to `list-style-type` and `@counter-style`. You just want the actual counter value as an integer, which we'll need a dedicated function for.)

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6408#issuecomment-2707873777 using your GitHub account


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

Received on Saturday, 8 March 2025 01:39:09 UTC