Skip to content

Commit 6725e51

Browse files
committed
serializing values ftw -- also win
1 parent 9e8f26e commit 6725e51

2 files changed

Lines changed: 90 additions & 77 deletions

File tree

cssom/Overview.html

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ <h3 id=common-serializing-idioms><span class=secno>2.3. </span>Common
411411
separating them by "<code>,</code>" (U+002C), followed by a space
412412
(U+0020).
413413

414+
<p>To <dfn id=serialize-a-whitespace-separated-list>serialize a
415+
whitespace-separated list</dfn> concatenate all items of the list in list
416+
order while separating them a space (U+0020).
417+
414418
<h2 id=media-queries><span class=secno>3. </span>Media Queries</h2>
415419

416420
<p><dfn id="media queries">Media queries</dfn> are defined by the Media
@@ -3470,47 +3474,53 @@ <h4 id=serializing-css-values><span class=secno>5.6.2. </span>Serializing
34703474
CSS Values</h4>
34713475
<!-- based on http://damowmow.com/playground/canon.txt -->
34723476

3473-
<p>To <dfn id=serialize-a-css-value>serialize a CSS value</dfn> run these
3474-
steps:
3477+
<p>To <dfn id=serialize-a-css-value>serialize a CSS value</dfn> follow
3478+
these rules:
34753479

3476-
<p class=XXX>This needs some work, obviously.</p>
3477-
<!--
3478-
<li><p>Where multiple values may appear in any order without changing the
3479-
meaning of the value (typically represented by a double bar <code>||</code>
3480-
in the value syntax), user agents are to use the canonical order as given in
3481-
the syntax (e.g. <code>&lt;border-width> &lt;border-style> &lt;color></code>
3482-
for the <code>border</code> short-hand property).</p></li>
3483-
3484-
<li><p>When repeated values may be omitted without changing the meaning of
3485-
the value (e.g. as in the <code>margin</code> and <code>padding</code>
3486-
properties), then the fewest number of values should be given.</p></li>
3487-
3488-
<li><p>If whitespace may be removed without changing the meaning of the value
3489-
it is to be removed.</p></li>
3490-
3491-
<li><p>Where components of the value may be dropped without changing the
3492-
meaning of the value (for example, initial values in shorthand properties),
3493-
then they should be removed. If this would remove all the values, then the
3494-
first allowed value must be given (For example, for <code>background</code>
3495-
that would be <code>rgba(0, 0, 0, 0)</code> since
3496-
<code>background-color</code> is the first component of the value; for
3497-
<code>border</code> it would be <code>0</code> since the first component of
3498-
that value is <code>border-width</code>).</p></li>
3499-
3500-
<li>
3501-
<p>A single space should be added after each comma that is not part of a
3502-
string, except where that would change the meaning of the value. For
3503-
example:</p>
3504-
3505-
<pre>foo,bar,baz</pre>
3506-
3507-
<p>should become:</p>
3508-
3509-
<pre>foo, bar, baz</pre>
3480+
<ul>
3481+
<li>
3482+
<p><a href="#serialize-a-css-value-component" title="Serialize a CSS
3483+
value component">Serialize</a> any CSS value components in the value.
3484+
3485+
<li>
3486+
<p>Where multiple CSS value components can appear in any order without
3487+
changing the meaning of the value (typically represented by a double bar
3488+
<code>||</code> in the value syntax), use the order as given in the
3489+
syntax.
35103490
</li>
3511-
3512-
</ol>
3513-
-->
3491+
<!-- <code>&lt;border-width> &lt;border-style> &lt;color></code>
3492+
for <code>border</code> -->
3493+
3494+
<li>
3495+
<p>Where CSS value components of the value can be omitted without
3496+
changing the meaning of the value (e.g. initial values in shorthand
3497+
properties), omit them. If this would remove all the values, then
3498+
include the first allowed value.</p>
3499+
3500+
<p class=example>E.g. <code>margin: 20px 20px</code> becomes
3501+
<code>margin: 20px</code>.</p>
3502+
3503+
<p class=example>E.g. the value <code>0</code> for the
3504+
'<code>border</code>' property.</p>
3505+
3506+
<li>
3507+
<p>If the value of a shorthand property is requested and it cannot be
3508+
computed because the properties associated with the shorthand have
3509+
values that cannot be represented by the shorthand the serialization is
3510+
the empty string.
3511+
3512+
<li>
3513+
<p>If a value has a <a href="#whitespace">whitespace</a>-separated list
3514+
of CSS value components, <a
3515+
href="#serialize-a-whitespace-separated-list" title="serialize a
3516+
whitespace-separated list">serialize</a> the value as a
3517+
whitespace-separated list.
3518+
3519+
<li>
3520+
<p>If a value has a comma-separated list of CSS value components, <a
3521+
href="#serialize-a-comma-separated-list" title="serialize a
3522+
comma-separated list">serialize</a> the value as a comma-separated list.
3523+
</ul>
35143524

35153525
<p>To <dfn id=serialize-a-css-value-component>serialize a CSS value
35163526
component</dfn> depends on the component, as follows:

cssom/Overview.src.html

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,13 @@ <h3>Common Serializing Idioms</h3>
213213
"<code title="">url(</code>", followed by the
214214
<span title="serialize a string">string escaped</span> value of the given
215215
string, followed by "<code>)</code>".</p>
216-
216+
217217
<p>To <dfn>serialize a comma-separated list</dfn> concatenate all items of
218218
the list in list order while separating them by "<code>,</code>" (U+002C),
219219
followed by a space (U+0020).</p>
220-
220+
221+
<p>To <dfn>serialize a whitespace-separated list</dfn> concatenate all
222+
items of the list in list order while separating them a space (U+0020).</p>
221223

222224

223225
<h2>Media Queries</h2>
@@ -2147,48 +2149,49 @@ <h4>Serializing CSS Values</h4>
21472149

21482150
<!-- based on http://damowmow.com/playground/canon.txt -->
21492151

2150-
<p>To <dfn id="serialize-a-css-value">serialize a CSS value</dfn> run
2151-
these steps:</p>
2152+
<p>To <dfn id="serialize-a-css-value">serialize a CSS value</dfn> follow
2153+
these rules:</p>
21522154

2153-
<p class="XXX">This needs some work, obviously.</p>
2155+
<ul>
2156+
<li><p><span title="Serialize a CSS value component">Serialize</span> any
2157+
CSS value components in the value.</p></li>
21542158

2155-
<!--
2156-
<li><p>Where multiple values may appear in any order without changing the
2157-
meaning of the value (typically represented by a double bar <code>||</code>
2158-
in the value syntax), user agents are to use the canonical order as given in
2159-
the syntax (e.g. <code>&lt;border-width> &lt;border-style> &lt;color></code>
2160-
for the <code>border</code> short-hand property).</p></li>
2161-
2162-
<li><p>When repeated values may be omitted without changing the meaning of
2163-
the value (e.g. as in the <code>margin</code> and <code>padding</code>
2164-
properties), then the fewest number of values should be given.</p></li>
2165-
2166-
<li><p>If whitespace may be removed without changing the meaning of the value
2167-
it is to be removed.</p></li>
2168-
2169-
<li><p>Where components of the value may be dropped without changing the
2170-
meaning of the value (for example, initial values in shorthand properties),
2171-
then they should be removed. If this would remove all the values, then the
2172-
first allowed value must be given (For example, for <code>background</code>
2173-
that would be <code>rgba(0, 0, 0, 0)</code> since
2174-
<code>background-color</code> is the first component of the value; for
2175-
<code>border</code> it would be <code>0</code> since the first component of
2176-
that value is <code>border-width</code>).</p></li>
2159+
<li><p>Where multiple CSS value components can appear in any order
2160+
without changing the meaning of the value (typically represented by a
2161+
double bar <code>||</code> in the value syntax), use the order as given
2162+
in the syntax.</p></li>
2163+
<!-- <code>&lt;border-width> &lt;border-style> &lt;color></code>
2164+
for <code>border</code> -->
21772165

21782166
<li>
2179-
<p>A single space should be added after each comma that is not part of a
2180-
string, except where that would change the meaning of the value. For
2181-
example:</p>
2182-
2183-
<pre>foo,bar,baz</pre>
2184-
2185-
<p>should become:</p>
2186-
2187-
<pre>foo, bar, baz</pre>
2167+
<p>Where CSS value components of the value can be omitted without
2168+
changing the meaning of the value (e.g. initial values in shorthand
2169+
properties), omit them. If this would remove all the values, then
2170+
include the first allowed value.</p>
2171+
2172+
<p class="example">E.g. <code>margin: 20px 20px</code> becomes
2173+
<code>margin: 20px</code>.</p>
2174+
2175+
<p class="example">E.g. the value <code>0</code> for the
2176+
'<code>border</code>' property.</p>
21882177
</li>
2178+
2179+
<li><p>If the value of a shorthand property is requested and it cannot be
2180+
computed because the properties associated with the shorthand have values
2181+
that cannot be represented by the shorthand the serialization is the
2182+
empty string.</p></li>
21892183

2190-
</ol>
2191-
-->
2184+
<li><p>If a value has a <span>whitespace</span>-separated list of
2185+
CSS value components,
2186+
<span title="serialize a whitespace-separated list">serialize</span> the
2187+
value as a whitespace-separated list.</p></li>
2188+
2189+
<li><p>If a value has a comma-separated list of
2190+
CSS value components,
2191+
<span title="serialize a comma-separated list">serialize</span> the
2192+
value as a comma-separated list.</p></li>
2193+
</ul>
2194+
21922195

21932196
<p>To
21942197
<dfn id="serialize-a-css-value-component">serialize a CSS value component</dfn>

0 commit comments

Comments
 (0)