From 28cf15d0e12b2687b51087d9a23338bb14498c79 Mon Sep 17 00:00:00 2001 From: Tab Atkins-Bittner Date: Thu, 25 Jul 2019 13:13:18 -0700 Subject: [PATCH] [css-variables] Better define invalid-at-cvt and cyclic-at-cvt, and the 'guaranteed-invalid value' concept. Fixes #4075. --- css-variables-1/Overview.bs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/css-variables-1/Overview.bs b/css-variables-1/Overview.bs index 347ba0e9ff3..1eecc55beb7 100644 --- a/css-variables-1/Overview.bs +++ b/css-variables-1/Overview.bs @@ -59,10 +59,10 @@ Defining Custom Properties: the '--*' family of properties
 	Name: --*
 	Value: <>?
-	Initial: (nothing, see prose)
+	Initial: the [=guaranteed-invalid value=]
 	Applies to: all elements
 	Inherited: yes
-	Computed value: specified value with variables substituted (but see prose for "invalid variables")
+	Computed value: specified value with variables substituted, or the [=guaranteed-invalid value=]
 	Animatable: no
 	
@@ -262,6 +262,22 @@ Custom Property Value Syntax to make maintaining the translations simpler. +

+Guaranteed-Invalid Values

+ + The initial value of a [=custom property=] is a guaranteed-invalid value. + As defined in [[#using-variables]], + using ''var()'' to substitute a [=custom property=] with this as its value + makes the property referencing it [=invalid at computed-value time=]. + + This value serializes as the empty string, + but actually writing an empty value into a custom property, + like ''--foo: ;'', + is a valid (empty) value, + not the [=guaranteed-invalid value=]. + If, for whatever reason, + one wants to manually reset a variable to the [=guaranteed-invalid value=], + using the keyword ''initial'' will do this.

@@ -281,10 +297,19 @@ Resolving Dependency Cycles

(including in the fallback argument of ''var()''), add an edge between prop and the var. Edges are possible from a custom property to itself. + If there is a cycle in the dependency graph, all the custom properties in the cycle - must compute to their initial value - (which is a guaranteed-invalid value). + are cyclic at computed-value time, + and must compute to the [=guaranteed-invalid value=]. + + Note: Defined properties that participate in a dependency cycle + either end up with invalid variables in their value + (becoming [=invalid at computed-value time=]), + or define their own cyclic handling + (like 'font-size' using ''em'' values). + They do not computed to the [=guaranteed-invalid value=] + like custom properties do.
This example shows a custom property safely using a variable: