Skip to content

[css-properties-values-api] [css-variables] Should the spec document invalid variables and fallback more explicitly? #849

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

Open
ghost opened this issue Dec 22, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 22, 2018

Specs:
CSS Properties and Values: https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles-via-relative-units
CSS Variables: https://drafts.csswg.org/css-variables/#invalid-variables

Related spec bugs:
#821

Chromium recently changed their behaviour for fallback of registered custom properties (web-platform-tests/wpt#14039).

It seems to me that the spec is not clear enough about when values should act as initial vs unset. For example, in Chromium, if an unregistered property has a cycle, it is reset to its initial (known-invalid) value. If that variable is registered, it is set to an invalid value regardless of its initial value or its parent's value.

If an undefined or invalid variable is substituted into a property, it is treated as unset. Unless that property is a registered custom property, in which case it is treated as unset but when substituting it, it seems to act like invalid. Relative dependency cycles are treated as unset, however.

Here is a fiddle to demonstrate: https://jsfiddle.net/nzyfu1td/13/. This might be Chrome-specific and I am probably missing something here, but I think it would be nice if the spec could clarify all of these cases explicitly.

@andruud
Copy link
Member

andruud commented Jan 18, 2019

What I find confusing, is that CSS Variables currently use the term "initial" to mean invalid-for-substitution-value. This is of course because the initial value for unregistered custom properties always is the invalid-for-substitution-value, but it becomes confusing when the initial value can be something else.

Should probably go through CSS Variables, and make sure that it consistently uses the term "unset" when it means unset (i.e. invalid-for-substitution-value for unregistered properties, initial for non-inherited registered properties, and inherit for inherited registered properties), and "invalid value for substitution" (or something) when that's the intent.

@FremyCompany
Copy link
Contributor

+1

@andruud
Copy link
Member

andruud commented Jul 29, 2020

@justinmichaud-2 The distinction between invalid at computed-value time and cyclic at computed-value time was added to css-variables a while back. In additions, all browsers have now shipped a consistent behavior for treating IACVT as 'unset' in all cases (see w3c/csswg-drafts#4075). Is this good enough to close this issue?

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