@@ -112,6 +112,7 @@ spec:css-namespaces-3; type:dfn; text:namespace prefix
112
112
spec:dom; type:interface; text:Document
113
113
spec:html; type:dfn; text:ascii case-insensitive
114
114
spec:html; type:dfn; text:case-sensitive
115
+ spec:infra; type:dfn; text:list
115
116
spec:css-logical; type:property; text:inline-size
116
117
spec:css-variables-1; type:dfn; text:custom property
117
118
spec:selectors-3; type:selector; text:::before
@@ -2464,33 +2465,49 @@ part of the property value space and will therefore cause
2464
2465
2465
2466
<!-- based on http://damowmow.com/playground/canon.txt -->
2466
2467
2467
- To <dfn>serialize a CSS value</dfn> of a <a>CSS declaration</a> <var> declaration</var> or a list of longhand <a lt="CSS declaration">CSS
2468
- declarations</a> <var> list</var> , follow these rules:
2468
+ To <dfn>serialize a CSS value</dfn> of a <a>CSS declaration</a> |declaration|
2469
+ or a list of longhand <a lt="CSS declaration">CSS declarations</a> |list|,
2470
+ follow these rules:
2471
+
2472
+ 1. If this algorithm is invoked with a [=list=] |list|:
2473
+ 1. Let |shorthand| be the first shorthand property,
2474
+ in [=preferred order=] ,
2475
+ that exactly maps to all of the longhand properties in |list|.
2476
+ 2. If there is no such shorthand or
2477
+ |shorthand| cannot exactly represent the values of all the properties in |list|,
2478
+ return the empty string.
2479
+ 3. Otherwise, [=serialize a CSS value=]
2480
+ from a hypothetical declaration of the property |shorthand|
2481
+ with its value representing the combined values of the declarations in |list|.
2482
+ 2. Represent the value of the |declaration|
2483
+ as a [=list=] of CSS component values |components|
2484
+ that, when [=CSS/parsed=] according to the property's grammar,
2485
+ would represent that value.
2486
+ Additionally:
2487
+
2488
+ * If certain component values can appear in any order
2489
+ without changing the meaning of the value
2490
+ (a pattern typically represented by a double bar <a grammar>||</a> in the value syntax),
2491
+ reorder the component values to use the canonical order of component values
2492
+ as given in the property definition table.
2493
+ * If component values can be omitted or replaced with a shorter representation
2494
+ without changing the meaning of the value,
2495
+ omit/replace them.
2496
+ * If either of the above syntactic translations would be less backwards-compatible,
2497
+ do not perform them.
2498
+
2499
+ Note: The rules described here outlines the <em> general principles</em> of serialization.
2500
+ For legacy reasons, some properties serialize in a different manner,
2501
+ which is intentionally undefined here due to lack of resources.
2502
+ Please consult your local reverse-engineer for details.
2503
+ 3. Remove any <<whitespace-token>> s from |components|.
2504
+ 3. Replace each component value in |components|
2505
+ with the result of invoking [=serialize a CSS component value=] .
2506
+ 4. Join the items of |components| into a single string,
2507
+ inserting " " (U+0020 SPACE) between each pair of items
2508
+ unless the second item is a "," (U+002C COMMA)
2509
+ Return the result.
2469
2510
2470
- <ol>
2471
- <li> If this algorithm is invoked with a list <var> list</var> , follow these substeps:
2472
- <ol>
2473
- <li> Let <var> shorthand</var> be the shorthand property that exactly maps to all the longhand properties in <var> list</var> . If there are multiple such
2474
- shorthand properties, use the first in <a>preferred order</a> .
2475
- <li> If <var> shorthand</var> cannot represent the values of <var> list</var> in its grammar, then return the empty string.
2476
- <li> Let <var> trimmed list</var> be a new empty array.
2477
- <li> For each <a>CSS declaration</a> <var> declaration</var> in <var> list</var> , if <var> declaration</var> 's
2478
- <a for="CSS declaration">value</a> is not the initial value, or if
2479
- <var> declaration</var> is a required component of the <var> shorthand</var> property, append <var> declaration</var> to <var> trimmed list</var> .
2480
- <li> If <var> trimmed list</var> is empty, append the value of the first item in <var> list</var> to <var> trimmed list</var> .
2481
- <li> Let <var> values</var> be a new empty array.
2482
- <li> For each <a>CSS declaration</a> <var> declaration</var> in <var> trimmed list</var> , invoke <a>serialize a CSS value</a> of
2483
- <var> declaration</var> , and append the result to <var> values</var> .
2484
- <li> Return the result of joining <var> values</var> as appropriate according to the grammar of <var> shorthand</var> .
2485
- </ol>
2486
- <li> Let <var> values</var> be a new empty array.
2487
- <li> Append the result of invoking <a>serialize a CSS component value</a> of <var> declaration</var> 's
2488
- <a for="CSS declaration">value</a> to <var> values</var> .
2489
- <li> If the grammar of the <a for="CSS declaration">property name</a> of <var> declaration</var> is defined to be
2490
- whitespace-separated, return the result of invoking <a>serialize a whitespace-separated list</a> of <var> values</var> .
2491
- <li> If the grammar of the <a for="CSS declaration">property name</a> of <var> declaration</var> is defined to be comma-separated,
2492
- return the result of invoking <a>serialize a comma-separated list</a> of <var> values</var> .
2493
- </ol>
2494
2511
2495
2512
To
2496
2513
<dfn>serialize a CSS component value</dfn>
0 commit comments