Skip to content

[css-values-5] Should an empty {} match <declaration-value> and <any-value> in functions? #11043

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

Closed
cdoublev opened this issue Oct 17, 2024 · 4 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-values-5

Comments

@cdoublev
Copy link
Collaborator

Considering the emphasized part below, I would say no because <declaration-value> and <any-value> require one or more tokens:

If it does start with a "{" token, then the production matches just the {} block that the "{" token opens. It represents the contents of that block, and applies whatever specific restrictions it defines for itself to those contents, ignoring the {} block wrapper.

https://drafts.csswg.org/css-values-5/#comma-containing-productions

However, it matches <whole-value>, right? No use case in mind, I just want to be sure.

@cdoublev
Copy link
Collaborator Author

I cannot see how fn({}) could reasonably match fn(<declaration-value>?), since the argument does not match <declaration-value> but is also not omitted (the input is not fully consumed). ? is not part of the comma-containing production, unless otherwise specified (excluding other multipliers).

And it seems a bit odd that color: first-valid({}, red) should be invalid because its arguments do not match <declaration-value>#.

cdoublev added a commit to cdoublev/css that referenced this issue Oct 18, 2024
It is not yet clear whether `{}` should match `<declaration-value>?` (w3c/csswg-drafts#11043).
@Loirooriol
Copy link
Contributor

I guess {} matches <declaration-value>? but not <declaration-value>

@cdoublev
Copy link
Collaborator Author

So a {}-block in a function at the location of a comma-containing production, would be somewhat similar to a whitespace. It is not represented in the syntax definition. It can be present in the input and change the syntax of the contents. But when it is alone, it is as if nothing is present. Alright.

@cdoublev
Copy link
Collaborator Author

Matching an optional production with a "concrete" token seems somewhat unusual for a language parser but in hindsight, I think no clarification is needed. first-valid() is intentionally defined to accept non-empty arguments, so there is no reason for an author to expect first-valid({}, valid) to be valid if it already knows first-valid(, valid) is not.

So closing as question answered.

@cdoublev cdoublev added the Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-values-5
Projects
None yet
Development

No branches or pull requests

2 participants