Skip to content

Commit b50d58b

Browse files
emiliofantasai
authored andcommitted
[cssom] Reduce by one the level of indentation of the "serialize a CSS declaration block" algo.
By moving `longhands` into the loop we can also avoid removing from it dynamically when serializing a given shorthand.
1 parent a686dd8 commit b50d58b

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

cssom-1/Overview.bs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,30 +2074,27 @@ To <dfn export>serialize a CSS declaration block</dfn> <var>declaration block</v
20742074
<li>Let <var>property</var> be <var>declaration</var>'s <a for="CSS declaration">property name</a>.
20752075
<li>If <var>property</var> is in <var>already serialized</var>, continue with the steps labeled <i>declaration loop</i>.
20762076
<li>If <var>property</var> maps to one or more shorthand properties, let <var>shorthands</var> be an array of those shorthand properties, in
2077-
<a>preferred order</a>, and follow these substeps:
2077+
<a>preferred order</a>.
2078+
<li><i>Shorthand loop</i>: For each <var>shorthand</var> in <var>shorthands</var>, follow these substeps:
20782079
<ol>
20792080
<li>Let <var>longhands</var> be an array consisting of all <a>CSS declarations</a> in <var>declaration block</var>'s
20802081
<a for="CSSStyleDeclaration">declarations</a> that that are not in <var>already serialized</var> and have a
20812082
<a for="CSS declaration">property name</a> that
20822083
maps to one of the shorthand properties in <var>shorthands</var>.
2083-
<li><i>Shorthand loop</i>: For each <var>shorthand</var> in <var>shorthands</var>, follow these substeps:
2084-
<ol>
2085-
<li>If all properties that map to <var>shorthand</var> are not present in <var>longhands</var>, continue with the steps labeled <i>shorthand loop</i>.
2086-
<li>Let <var>current longhands</var> be an empty array.
2087-
<li>Append all <a>CSS declarations</a> in <var>longhands</var> have a
2088-
<a for="CSS declaration">property name</a> that maps to <var>shorthand</var> to <var>current longhands</var>.
2089-
<li>If there is one or more <a>CSS declarations</a> in <var>current longhands</var> have their
2090-
<a for="CSS declaration">important flag</a> set and one or more with it unset, continue with
2091-
the steps labeled <i>shorthand loop</i>.
2092-
<li>Let <var>value</var> be the result of invoking <a>serialize a CSS value</a> of <var>current longhands</var>.
2093-
<li>If <var>value</var> is the empty string, continue with the steps labeled <i>shorthand loop</i>.
2094-
<li>Let <var>serialized declaration</var> be the result of invoking <a>serialize a CSS declaration</a> with property name
2095-
<var>shorthand</var>, value <var>value</var>, and the <i>important</i> flag set if the <a>CSS declarations</a> in
2096-
<var>current longhands</var> have their <a for="CSS declaration">important flag</a> set.
2097-
<li>Append <var>serialized declaration</var> to <var>list</var>.
2098-
<li>Append the property names of all items of <var>current longhands</var> to <var>already serialized</var>.
2099-
<li>Remove the items present in <var>current longhands</var> from <var>longhands</var>.
2100-
</ol>
2084+
<li>If all properties that map to <var>shorthand</var> are not present in <var>longhands</var>, continue with the steps labeled <i>shorthand loop</i>.
2085+
<li>Let <var>current longhands</var> be an empty array.
2086+
<li>Append all <a>CSS declarations</a> in <var>longhands</var> have a
2087+
<a for="CSS declaration">property name</a> that maps to <var>shorthand</var> to <var>current longhands</var>.
2088+
<li>If there is one or more <a>CSS declarations</a> in <var>current longhands</var> have their
2089+
<a for="CSS declaration">important flag</a> set and one or more with it unset, continue with
2090+
the steps labeled <i>shorthand loop</i>.
2091+
<li>Let <var>value</var> be the result of invoking <a>serialize a CSS value</a> of <var>current longhands</var>.
2092+
<li>If <var>value</var> is the empty string, continue with the steps labeled <i>shorthand loop</i>.
2093+
<li>Let <var>serialized declaration</var> be the result of invoking <a>serialize a CSS declaration</a> with property name
2094+
<var>shorthand</var>, value <var>value</var>, and the <i>important</i> flag set if the <a>CSS declarations</a> in
2095+
<var>current longhands</var> have their <a for="CSS declaration">important flag</a> set.
2096+
<li>Append <var>serialized declaration</var> to <var>list</var>.
2097+
<li>Append the property names of all items of <var>current longhands</var> to <var>already serialized</var>.
21012098
</ol>
21022099
<li>If <var>property</var> is in <var>already serialized</var>, continue with the steps labeled <i>declaration loop</i>.
21032100
<li>Let <var>value</var> be the result of invoking <a>serialize a CSS value</a> of <var>declaration</var>.

0 commit comments

Comments
 (0)