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-5] Accept <whole-value> as argument of first-valid() #9590

Closed
cdoublev opened this issue Nov 10, 2023 · 4 comments
Closed

[css-values-5] Accept <whole-value> as argument of first-valid() #9590

cdoublev opened this issue Nov 10, 2023 · 4 comments

Comments

@cdoublev
Copy link
Collaborator

Is first-valid() intentionally defined with <declaration-value> rather than <whole-value>? Should first-valid(toggle(red; green)) be invalid?

https://drafts.csswg.org/css-values-5/#typedef-first-valid

<first-valid()> = first-valid( <declaration-value> [ ';' <declaration-value> ]* )

@Loirooriol
Copy link
Contributor

Loirooriol commented Nov 10, 2023

Accept <whole-value> as argument of first-valid()

I thought the same in 5fc63f5#r131685583

But e.g. consider color: first-valid(invalid(); green). This needs to be valid (and resolve to green), so we can't require invalid() to be a <whole-value>.

Should first-valid(toggle(red; green)) be invalid?

No, it's valid, since toggle(red; green) is a <declaration-value> (being a <whole-value> is not exclusive).

@cdoublev
Copy link
Collaborator Author

cdoublev commented Nov 10, 2023

Ah yes, sorry, first-valid() arguments should be validated at computed value time:

If none of the arguments represent a valid value for the property, the property is invalid at computed-value time.

I am still not sure if toggle() nested in first-valid() is valid at computed value time (it is not allowed to be nested), or at parse time in other cases (eg. toggle(toggle(red); green) or mix(50%; toggle(red); green)).

Thanks for the clarification!

@Loirooriol
Copy link
Contributor

I am still not sure if toggle() nested in first-valid() is valid at computed value time

toggle() is not preserved at computed-value time. https://drafts.csswg.org/css-values-5/#toggle-notation: "the computed value of toggle() is C_{n+1}"

it is not allowed to be nested

I think this means that you can't have a toggle() inside another toggle(). But it should be fine to have a toggle() inside a first-valid().

@tabatkins
Copy link
Member

Yeah @Loirooriol is correct on all counts.

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

3 participants