Skip to content

Commit 28cf15d

Browse files
committed
[css-variables] Better define invalid-at-cvt and cyclic-at-cvt, and the 'guaranteed-invalid value' concept. Fixes #4075.
1 parent 81b3421 commit 28cf15d

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

css-variables-1/Overview.bs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Defining Custom Properties: the '--*' family of properties</h2>
5959
<pre class='propdef'>
6060
Name: --*
6161
Value: <<declaration-value>>?
62-
Initial: (nothing, see prose)
62+
Initial: the [=guaranteed-invalid value=]
6363
Applies to: all elements
6464
Inherited: yes
65-
Computed value: specified value with variables substituted (but see prose for "invalid variables")
65+
Computed value: specified value with variables substituted, or the [=guaranteed-invalid value=]
6666
Animatable: no
6767
</pre>
6868

@@ -262,6 +262,22 @@ Custom Property Value Syntax</h3>
262262
to make maintaining the translations simpler.
263263
</div>
264264

265+
<h3 id='guaranteed-invalid'>
266+
Guaranteed-Invalid Values</h3>
267+
268+
The initial value of a [=custom property=] is a <dfn export>guaranteed-invalid value</dfn>.
269+
As defined in [[#using-variables]],
270+
using ''var()'' to substitute a [=custom property=] with this as its value
271+
makes the property referencing it [=invalid at computed-value time=].
272+
273+
This value serializes as the empty string,
274+
but actually writing an empty value into a custom property,
275+
like ''--foo: ;'',
276+
is a valid (empty) value,
277+
not the [=guaranteed-invalid value=].
278+
If, for whatever reason,
279+
one wants to manually reset a variable to the [=guaranteed-invalid value=],
280+
using the keyword ''initial'' will do this.
265281

266282

267283
<h3 id='cycles'>
@@ -281,10 +297,19 @@ Resolving Dependency Cycles</h3>
281297
(including in the fallback argument of ''var()''),
282298
add an edge between <var>prop</var> and the <var>var</var>.
283299
<span class='note'>Edges are possible from a custom property to itself.</span>
300+
284301
If there is a cycle in the dependency graph,
285302
all the <a>custom properties</a> in the cycle
286-
must compute to their initial value
287-
(which is a guaranteed-invalid value).
303+
are <dfn export>cyclic at computed-value time</dfn>,
304+
and must compute to the [=guaranteed-invalid value=].
305+
306+
Note: Defined properties that participate in a dependency cycle
307+
either end up with invalid variables in their value
308+
(becoming [=invalid at computed-value time=]),
309+
or define their own cyclic handling
310+
(like 'font-size' using ''em'' values).
311+
They do not computed to the [=guaranteed-invalid value=]
312+
like custom properties do.
288313

289314
<div class='example'>
290315
This example shows a custom property safely using a variable:

0 commit comments

Comments
 (0)