Skip to content
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

[css-values-4][css-variables] Parsing priority between substitution values #8731

Closed
cdoublev opened this issue Apr 19, 2023 · 2 comments
Closed

Comments

@cdoublev
Copy link
Collaborator

Does parsing arbitrary substitution values (var(), attr(), random-item()) has priority over parsing other substitution values (mix() and toggle())?

For example, is animation-duration: mix(50%; invalid; var(--end)) extra valid?

A mix() notation is invalid if it is not the sole value of the property; if either of its <declaration-value>s are invalid when specified as the entire value for the property the function is used in; or if the property using it is not animatable.

https://w3c.github.io/csswg-drafts/css-values-4/#interpolate

If a property contains one or more var() functions, and those functions are syntactically valid, the entire property’s grammar must be assumed to be valid at parse time.

https://w3c.github.io/csswg-drafts/css-variables-2/#using-variables

@Loirooriol
Copy link
Contributor

display: var(--foo) somethinginvalid parses as valid, then becomes invalid at computed value time.

I don't see why it should be different with mix().

@cdoublev
Copy link
Collaborator Author

cdoublev commented Apr 19, 2023

It could be different in my example because:

  • mix() is not the sole value of the property
  • animation-duration is not animatable
  • invalid is an invalid value for animation-duration.

And it turns out that it must be different for toggle() (emphasize added):

The toggle() notation is not allowed to be nested; nor may it contain attr() or calc() notations.

edit

I think the text I cited above predates the current definition of attr(), var(), and any other arbitrary substitution value, so it does not mean that toggle() cannot be nested nor may it contain an arbitrary substitution value.

And I missed your point, that arbitrary substitution values like var() should take priority regardless of whether the value is invalid according to the grammar of the property or another substitution value like mix().

And since toggle(red; green) var(--custom) can be valid at computed value time if var(--custom) is substituted with an empty string, you are right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@tabatkins @fantasai @Loirooriol @cdoublev and others