-
Notifications
You must be signed in to change notification settings - Fork 715
[css-values] String parsing function (replaces multi-value attr()
)
#3702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We’d still probably need a fallback argument for |
Other than implementing the attr()-with-type functionality, what other use-case would there be for this? We can't work around "browsers aren't implementing X" by creating a Y that's identical to X. Notably, both of your example are just exactly attr()-with-type, except attr() is easier to read: .icon {
content: attr(href image, url("fallback.png"));
width: attr(data-width var(--icon-unit), 1em);
} |
Yeah, I guess I don't have a lot of other good use cases. Being able to concat together a unit value and a number value and then parse them as a length would be another case, but it can be solved by the The only other time where I see people complain about the difference between strings and numbers is for Mostly, this issue was because I didn't understand why the full |
With the discussion in #542 about converting non-string variables to string, it's worth discussing the reverse: a parser function that can take a string and parse it according to a specified CSS grammar.
Such a function could replace the multi-value
attr()
function that was supposed to allow authors to extract typed values from attributes. The type-awareattr()
function is not supported in any current web browsers; I'm not sure if it has support in other CSS environments.At the same time, a general parsing function could be used with CSS variables, or with strings generated by combining variables with the new concatenation function in ways that require re-tokenization.
Suggested syntax:
It would use syntax strings as defined in the Properties and Values API instead of the custom keywords in the current
attr()
definition.Examples:
The text was updated successfully, but these errors were encountered: