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

> Is this addressing any usecase not covered by #1026 and #542? Because I would prefer to address these with a specific solution for them.

Yes, explicit type conversion functions may also cover type conversion in `attr()` and possibly even complex types, as [noted earlier](https://github.com/w3c/csswg-drafts/issues/6408#issuecomment-1975079791) by @Crissov.

> Also it's not clear if converting string to number will accept scientific notation, leading/surrounding whitespace, strings like `"calc(1 + 3)"`, etc.

Any string that can be interpreted as a valid `<number>` value. That at least includes scientific notation. For math functions like `calc()`, I tend to say yes, to surrounding whitespace I'd say no. Though that needs to be discussed.

> Also not a fan of just dropping units. Converting `2em` into `2` is better achieved with `calc(2em / 1em)`.

So how would you convert a string `"2em"` into a number? Should it just fail?

Sebastian

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


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

Received on Sunday, 1 September 2024 00:44:38 UTC