Skip to content

Commit 321c596

Browse files
authored
[css-typed-om] clarify how CSSUnparsedValues compute. (#296)
(#192)
1 parent b6b62c3 commit 321c596

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

css-typed-om/Overview.bs

+27-15
Original file line numberDiff line numberDiff line change
@@ -1416,28 +1416,40 @@ appear as computed values (i.e. as a value stored on computed
14161416
Computed {{CSSUnparsedValue}} objects {#computed-unparsedvalue-objects}
14171417
-----------------------------------------------------------------------------
14181418

1419-
Custom property references are resolved as part of style computation. Accordingly,
1420-
computed {{CSSUnparsedValue}} objects will not contain {{CSSVariableReferenceValue}} objects.
1421-
As a result, only a single {{DOMString}} will appear in the sequence contained by
1422-
computed {{CSSUnparsedValue}} objects.
1423-
1424-
Furthermore, values that at specified value time contained custom property references
1425-
are renormalized after computation.
1419+
A property with a specified {{CSSUnparsedValue}} value will not
1420+
compute to a {{CSSUnparsedValue}}. Instead, after custom property references
1421+
are resolved, the {{CSSStyleValue}} subclass appropriate to the property will be
1422+
used.
14261423

14271424
<div class='example'>
1425+
For example, a style rule containing:
14281426

1429-
Consider an element "e" with an inline style that specifies a width of <code>var(--baz)</code>.
1427+
<pre class='style'>
1428+
width: calc(var(--foo) + 10%);
1429+
</pre>
14301430

1431-
Assuming that the custom property --baz contains the value "42px", running the following code:
1431+
Will represent a specified width as an {{CSSUnparsedValue}}, but if this value
1432+
is the winning value during computation for a given element then that element's
1433+
computed width will be represented by a {{CSSLengthValue}} object (assuming
1434+
that --foo resolves to a valid substitution).
1435+
</div>
14321436

1433-
<pre class='lang-javascript'>
1434-
var a = e.styleMap.get('width');
1435-
var b = getComputedStyleMap(e).get('width');
1436-
</pre>
1437+
Often there will be no {{CSSStyleValue}} subclass appropriate - for example when a custom property
1438+
contains a reference to another custom property. In these cases, a {{CSSStyleValue}}
1439+
is used directly to represent a valud of unknown type.
14371440

1438-
Will result in "a" containing a {{CSSUnparsedValue}} with a single {{CSSVariableReferenceValue}}
1439-
in its sequence, and "b" containing a {{CSSSimpleLength}} representing 42px.
1441+
<div class='example'>
1442+
1443+
For example, a style rule containing:
1444+
1445+
<pre class='style'>
1446+
--foo: var(--bar) black;
1447+
</pre>
14401448

1449+
Will represent a specified value for --foo as a {{CSSUnparsedValue}}, and if
1450+
this value is the winning declaration for --foo during computation for a given
1451+
element, then that element's will have a computed value for --foo that is
1452+
represented by a {{CSSStyleValue}}.
14411453
</div>
14421454

14431455
Computed {{CSSKeywordValue}} objects {#computed-keywordvalue-objects}

0 commit comments

Comments
 (0)