- From: Bramus via GitHub <sysbot+gh@w3.org>
- Date: Fri, 24 Jan 2025 16:36:31 +0000
- To: public-css-archive@w3.org
> In general, CSS functions don't guard against the possibility of some argument being invalid from a nonsense var() substitution. `attr()` has something like that built in, no? `attr(id type(<color>), blue)` will fall back to `blue` if it turns out that the `id` attribute cannot be parsed into a `<color>`. > Fair, one can always do a fallback with a separate variable: > > ```css > --name: ident(--color- var(--color)); > background: var(var(--name, --color-blue)); > ``` I must say that the equivalent below is much easier to read _(I also added the ", knowing they are not really necessary)_: ```css --color: red; background: ident("--color-" var(--color), --color-blue); ``` You could also write the following, but that only holds up when the fallback starts with the same prefix ```css --color: red; background: ident("--color-" var(--color, blue)); ``` ```css --color: red; background: ident("--color-" var(--color), --default-bg-color); ``` -- GitHub Notification of comment by bramus Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11424#issuecomment-2612943094 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 24 January 2025 16:36:32 UTC