Skip to content

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

Open
@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions