Skip to content

Commit f3a2fe1

Browse files
committed
[css-typed-om] clarify how CSSUnparsedValues compute.
(#192)
1 parent 3e32d4a commit f3a2fe1

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
@@ -1419,28 +1419,40 @@ appear as computed values (i.e. as a value stored on computed
14191419
Computed {{CSSUnparsedValue}} objects {#computed-unparsedvalue-objects}
14201420
-----------------------------------------------------------------------------
14211421

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

14301427
<div class='example'>
1428+
For example, a style rule containing:
14311429

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

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

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

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

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

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

0 commit comments

Comments
 (0)