|
22 | 22 |
|
23 | 23 | <h1>CSS Variables Module Level 1</h1> |
24 | 24 |
|
25 | | - <h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 27 October |
| 25 | + <h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 30 October |
26 | 26 | 2011</h2> |
27 | 27 |
|
28 | 28 | <dl> |
29 | 29 | <dt>This version: |
30 | 30 |
|
31 | 31 | <dd><a |
32 | | - href="http://www.w3.org/TR/2011/ED-css-variables-20111027/">http://dev.w3.org/csswg/css-variables/</a> |
| 32 | + href="http://www.w3.org/TR/2011/ED-css-variables-20111030/">http://dev.w3.org/csswg/css-variables/</a> |
33 | 33 | <!--<dt>Latest version: |
34 | 34 | <dd><a href="http://www.w3.org/TR/css-variables/">http://www.w3.org/TR/css-variables/</a>--> |
35 | 35 |
|
@@ -274,7 +274,7 @@ <h2 id=defining-variables><span class=secno>2. </span> Defining Variables |
274 | 274 | <tr> |
275 | 275 | <th>Computed Value: |
276 | 276 |
|
277 | | - <td>specified value |
| 277 | + <td>specified value with variables substituted |
278 | 278 |
|
279 | 279 | <tr> |
280 | 280 | <th>Media: |
@@ -388,26 +388,40 @@ <h2 id=defining-variables><span class=secno>2. </span> Defining Variables |
388 | 388 | lengths.</p> |
389 | 389 | </div> |
390 | 390 |
|
391 | | - <div class=issue> |
392 | | - <p>Is it possible to do a "cyclic" dependency safely?</p> |
| 391 | + <p>It is important to note that <a href="#data-property"><i>data |
| 392 | + properties</i></a> resolve any <i>variables</i> in their values at |
| 393 | + computed-value time, which occurs <em>before</em> the value is inherited. |
| 394 | + In general, cyclic dependencies occur only when multiple data properties |
| 395 | + on the same element refer to each other; data properties defined on |
| 396 | + elements higher in the element tree can never cause a cyclic reference |
| 397 | + with properties defined on elements lower in the element tree. |
| 398 | + |
| 399 | + <div class=example> |
| 400 | + <p>For example, given the following structure, these data properties are |
| 401 | + <strong>not</strong> cyclic, and all define valid variables:</p> |
393 | 402 |
|
394 | 403 | <pre> |
395 | 404 | <one><two><three /></two></one> |
396 | 405 | one { data-foo: 10px; } |
397 | 406 | two { data-bar: calc(data(foo) + 10px); } |
398 | 407 | three { data-foo: calc(data(bar) + 10px); }</pre> |
399 | 408 |
|
400 | | - <p>If I'm thinking correctly, one and two would get the value ‘<code |
401 | | - class=css>10px</code>’ for ‘<code |
402 | | - class=css>data(foo)</code>’, but three overrides ‘<code |
403 | | - class=property>data-foo</code>’ with a new definition. It gets the |
404 | | - *inherited* value of ‘<code class=property>data-bar</code>’, |
405 | | - which is ‘<code class=css>calc(10px + 10px)</code>’ (or maybe |
406 | | - just ‘<code class=css>20px</code>’ - ‘<code |
407 | | - class=css>calc()</code>’ computed values aren't well defined yet), |
408 | | - so it seems like it validly sets ‘<code |
409 | | - class=property>data-foo</code>’ to ‘<code |
410 | | - class=css>30px</code>’. Right?</p> |
| 409 | + <p>The <one> element defines a value for ‘<code |
| 410 | + class=property>data-foo</code>’. The <two> element inherits this |
| 411 | + value, and additionally assigns a value to ‘<code |
| 412 | + class=property>data-bar</code>’. Finally, the <three> element |
| 413 | + inherits the ‘<code class=property>data-bar</code>’ value |
| 414 | + <em>after</em> variable substitution (in other words, it sees the value |
| 415 | + ‘<code class=css>calc(10px + 10px)</code>’), and then |
| 416 | + redefines ‘<code class=property>data-foo</code>’ in terms of |
| 417 | + that value. Since the value it inherited for ‘<code |
| 418 | + class=property>data-bar</code>’ no longer contains a reference to |
| 419 | + the ‘<code class=property>data-foo</code>’ property defined |
| 420 | + on <one>, defining ‘<code class=property>data-foo</code>’ |
| 421 | + using the ‘<code class=css>data(bar)</code>’ variable is not |
| 422 | + cyclic, and actually defines a value that will eventually (when |
| 423 | + referenced as a variable in a normal property) resolve to ‘<code |
| 424 | + class=css>30px</code>’.</p> |
411 | 425 | </div> |
412 | 426 |
|
413 | 427 | <p>The initial value of a <a href="#data-property"><i>data property</i></a> |
@@ -1041,7 +1055,7 @@ <h2 class=no-num id=property-index>Property index</h2> |
1041 | 1055 |
|
1042 | 1056 | <td>yes |
1043 | 1057 |
|
1044 | | - <td>specified value |
| 1058 | + <td>specified value with variables substituted |
1045 | 1059 |
|
1046 | 1060 | <td>all |
1047 | 1061 | </table> |
|
0 commit comments