Skip to content

Commit 6bcbd14

Browse files
committed
Rewrite CSSUnparsedValue serialization to be more explicit.
1 parent 6f75aff commit 6bcbd14

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

css-typed-om/Overview.bs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,16 +3032,36 @@ length3.toString(); // "42px";
30323032
{{CSSUnparsedValue}} Serialization {#unparsedvalue-serialization}
30333033
-----------------------------------------------------------------
30343034

3035-
{{CSSUnparsedValue}} objects are serialized by first serializing each
3036-
{{CSSVariableReferenceValue}}, then concatenating the contained DOMStrings and
3037-
{{CSSVariableReferenceValue}} serializations in order.
3038-
3039-
{{CSSVariableReferenceValue}} objects are serialized by the following process:
3040-
1. the fallback {{CSSUnparsedValue}} is serialized
3041-
2. if the fallback serialization is the empty string, then the
3042-
{{CSSVariableReferenceValue}} serializes as "var(" + variable + ")"
3043-
3. otherwise, the {{CSSVariableReferenceValue}} serializes as
3044-
"var(" + variable + "," + fallback serialization + ")"
3035+
<div algorithm>
3036+
To <dfn export>serialize a {{CSSUnparsedValue}}</dfn> |this|:
3037+
3038+
1. Let |s| initially be the empty [=string=].
3039+
3040+
2. [=list/For each=] |item| in |this|’s {{CSSUnparsedValue/[[tokens]]}} internal slot:
3041+
1. If |item| is a {{DOMString}},
3042+
append it to |s|.
3043+
2. Otherwise, |item| is a {{CSSVariableReferenceValue}}.
3044+
Serialize it,
3045+
then append the result to |s|.
3046+
3047+
3. Return |s|.
3048+
</div>
3049+
3050+
<div algorithm>
3051+
To <dfn>serialize a {{CSSVariableReferenceValue}}</dfn> |this|:
3052+
3053+
1. Let |s| initally be the [=string=] "var(".
3054+
3055+
2. Append |this|’s {{CSSVariableReferenceValue/variable}} internal slot to |s|.
3056+
3057+
3. If |this|’s {{CSSVariableReferenceValue/fallback}} internal slot is not `null`,
3058+
append ", " to |s|,
3059+
then serialize the {{CSSVariableReferenceValue/fallback}} internal slot
3060+
and append it to |s|.
3061+
3062+
4. Append ")" to |s|
3063+
and return |s|.
3064+
</div>
30453065

30463066
{{CSSKeywordValue}} Serialization {#keywordvalue-serialization}
30473067
---------------------------------------------------------------

0 commit comments

Comments
 (0)