Skip to content

Commit 2a4de87

Browse files
committed
[css-variables] Make it clearer how variable cycles work.
1 parent 3483d3f commit 2a4de87

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

css-variables/Overview.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</p>
5555
<h1 class="p-name no-ref" id=title>CSS Custom Properties for Cascading Variables Module Level 1</h1>
5656
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
57-
<span class=dt-updated><span class=value-title title=20131216>16 December 2013</span></span></span></h2>
57+
<span class=dt-updated><span class=value-title title=20131217>17 December 2013</span></span></span></h2>
5858
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-variables/>http://dev.w3.org/csswg/css-variables/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css-variables-1/>http://www.w3.org/TR/css-variables-1/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-variables/>http://dev.w3.org/csswg/css-variables/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2013/WD-css-variables-20130312/ rel=previous>http://www.w3.org/TR/2013/WD-css-variables-20130312/</a><dd><a href=http://www.w3.org/TR/2012/WD-css-variables-20120410/ rel=previous>http://www.w3.org/TR/2012/WD-css-variables-20120410/</a>
5959
<dt>Feedback:</dt>
6060
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-variables%5D%20feedback">www-style@w3.org</a>
@@ -384,9 +384,19 @@ <h3 class="heading settled heading" data-level=2.3 id=cycles><span class=secno>2
384384
<p> <a data-link-type=dfn href=#custom-property title="custom properties">Custom properties</a> may use variables in their own values to build up composite variables.
385385
This can create cyclic dependencies
386386
where a custom property uses its own variable,
387-
or two or more <a data-link-type=dfn href=#custom-property title="custom properties">custom properties</a> each attempt to use the variable that the other defines;
388-
doing so makes all the <a data-link-type=dfn href=#custom-property title="custom properties">custom properties</a> involved in the cycle
389-
compute to their initial value (which is a guaranteed-invalid value).
387+
or two or more <a data-link-type=dfn href=#custom-property title="custom properties">custom properties</a> each attempt to use the variable that the other defines.
388+
389+
<p> For each element,
390+
create an undirected dependency graph,
391+
containing nodes for each <a data-link-type=dfn href=#custom-property title="custom property">custom property</a>.
392+
If the value of a <a data-link-type=dfn href=#custom-property title="custom property">custom property</a> <var>prop</var> contains a <a data-link-type=dfn href=#variable title=variable>variable</a> <var>var</var>
393+
(including in the fallback of other <a data-link-type=dfn href=#variable title=variables>variables</a>),
394+
add an edge between <var>prop</var> and the <a data-link-type=dfn href=#custom-property title="custom property">custom property</a> associated with <var>var</var>.
395+
<span class=note>Edges are possible from a custom property to itself.</span>
396+
If there is a cycle in the dependency graph,
397+
all the <a data-link-type=dfn href=#custom-property title="custom properties">custom properties</a> in the cycle
398+
must compute to their initial value
399+
(which is a guaranteed-invalid value).
390400

391401
<div class=example>
392402
This example shows a custom property safely using a variable:

css-variables/Overview.src.html

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,19 @@ <h3 id='cycles'>
280280
<a>Custom properties</a> may use variables in their own values to build up composite variables.
281281
This can create cyclic dependencies
282282
where a custom property uses its own variable,
283-
or two or more <a>custom properties</a> each attempt to use the variable that the other defines;
284-
doing so makes all the <a>custom properties</a> involved in the cycle
285-
compute to their initial value (which is a guaranteed-invalid value).
283+
or two or more <a>custom properties</a> each attempt to use the variable that the other defines.
284+
285+
For each element,
286+
create an undirected dependency graph,
287+
containing nodes for each <a>custom property</a>.
288+
If the value of a <a>custom property</a> <var>prop</var> contains a <a>variable</a> <var>var</var>
289+
(including in the fallback of other <a>variables</a>),
290+
add an edge between <var>prop</var> and the <a>custom property</a> associated with <var>var</var>.
291+
<span class='note'>Edges are possible from a custom property to itself.</span>
292+
If there is a cycle in the dependency graph,
293+
all the <a>custom properties</a> in the cycle
294+
must compute to their initial value
295+
(which is a guaranteed-invalid value).
286296

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

0 commit comments

Comments
 (0)