Re: [csswg-drafts] [css-values-5] attr() and forwards compatible parsing (#11035)

In private conversation, @fantasai pointed out that, while this is nicely unambiguous, it's starting to get pretty heavy for simple cases. For example, to indicate that you want to parse the attribute as a number and interpret it as a px length, you'd write `attr(foo type(<number px>))`, where previously it was just `attr(foo px)`.

She suggests going with the `type()` wrapper, but *also* still allowing a handful of keywords to indicate "simple" grammars. I suggest:
* `string` for the "no interpretation, just the literal value as a string" case (currently indicated only by *omitting* the syntax arg)
* `value` for "parse it as a single CSS component value" (automatically recognizing it as a length/angle/number/ident/etc)
*  `px`/`em`/etc for "parse it as a number, then give it that unit".

This gives us the best of both worlds for this simple case. And I don't think it should extend to other users of `<syntax>`, like custom functions or custom properties - `string` value isn't meaningful for values already written in CSS, `value` imposes no meaningful restrictions so it's very nearly just `*` anyway, and `px`/etc are not a use-case we want to encourage in other places.

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


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

Received on Monday, 11 November 2024 21:05:27 UTC