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-variables][css-syntax] Whitespace trimming and var() fallbacks #6871

Open
andruud opened this issue Dec 9, 2021 · 4 comments
Open

[css-variables][css-syntax] Whitespace trimming and var() fallbacks #6871

andruud opened this issue Dec 9, 2021 · 4 comments
Labels
css-variables-1 Current Work

Comments

@andruud
Copy link
Member

andruud commented Dec 9, 2021

I'd like to clarify one detail regarding whitespace trimming defined by consume a declaration:

What is the computed value of --x here? --x: a var(--invalid, b );

I would interpret the current specs like this: the whitespace before a gets trimmed, but we don't remove any whitespace inside the value, so a var(--invalid, b ) (with no space in front) becomes the "parsed" value. Then, substitution-time, the var() reference resolves to its fallback _b_ (using _ for space), and the post-substitution value becomes a__b_. At this point it may make sense to behave as if relevant parts of "consume a declaration" had been invoked on the final post-substitution token sequence, trimming the result to a__b, although it's not really clear if this is expected.

OR, do we trim the spaces around the <declaration-value> of the fallback at some point instead (for example, "anything we substitute in gets trimmed first")? In that case, the computed value would be a_b.

@tabatkins @emilio

@emilio
Copy link
Collaborator

emilio commented Dec 9, 2021

I think trimming around the fallback is what I implemented in Gecko and seems a potentially more desirable result since it's common to put whitespace after the fallback comma, afaict.

@tabatkins
Copy link
Member

Yeah, it makes sense to trim around the fallback value. Happy to spec that.

@tabatkins tabatkins added the css-variables-1 Current Work label Dec 9, 2021
@tabatkins
Copy link
Member

Rather, <declaration-value> and <any-value> should probably trim whitespace around themselves. This'll be a no-op for custom properties themselves, since "parse a declaration" already does it, but it'll trim fallbacks and anywhere else that uses the productions.

@andruud
Copy link
Member Author

andruud commented Dec 9, 2021

Sounds good, as long as we make it clear exactly when this happens for custom properties, since that's a case of a <declaration-value> within a <declaration-value>.

For example, what happens if I use CSSOM to serialize the specified value of --x: var(--y,_b_)? ("_" being space).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-variables-1 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants