Skip to content

Commit 4471096

Browse files
authored
[cssom] Make CSSStyleRule serialization aware of nesting. (w3c#6117)
1 parent 297dcc2 commit 4471096

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

cssom-1/Overview.bs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,17 +1523,34 @@ To <dfn export>serialize a CSS rule</dfn>, perform one of the following in accor
15231523
<dl class="switch">
15241524
<dt>{{CSSStyleRule}}
15251525
<dd>
1526-
The result of concatenating the following:
1526+
Return the result of the following steps:
1527+
15271528
<ol>
1528-
<li>The result of performing <a>serialize a group of selectors</a> on the rule's associated selectors.
1529-
<li>The string "<code> { </code>", i.e., a single SPACE (U+0020), followed by LEFT CURLY BRACKET (U+007B),
1530-
followed by a single SPACE (U+0020).
1531-
<li>The result of performing <a>serialize a CSS declaration block</a> on the rule's associated declarations.
1532-
<li>If the rule is associated with one or more declarations, the string "<code> </code>", i.e., a single SPACE (U+0020).
1533-
<li>The string "<code>}</code>", RIGHT CURLY BRACKET (U+007D).
1529+
<li>Let |s| initially be
1530+
the result of performing <a>serialize a group of selectors</a> on the rule's associated selectors,
1531+
followed by the string "<code> {</code>", i.e., a single SPACE (U+0020), followed by LEFT CURLY BRACKET (U+007B).
1532+
<li>Let |decls| be the result of performing <a>serialize a CSS declaration block</a> on the rule's associated declarations, or null if there are no such declarations.
1533+
<li>Let |rules| be the result of performing [=serialize a CSS rule=] on each rule in the rule's {{CSSStyleRule/cssRules}} list, or null if there are no such rules.
1534+
<li>If |decls| and |rules| are both null, append " }" to |s| (i.e. a single SPACE (U+0020) followed by RIGHT CURLY BRACKET (U+007D)) and return |s|.
1535+
<li>If |rules| is null:
1536+
<ol>
1537+
<li>Append a single SPACE (U+0020) to |s|
1538+
<li>Append |decls| to |s|
1539+
<li>Append " }" to |s| (i.e. a single SPACE (U+0020) followed by RIGHT CURLY BRACKET (U+007D)).
1540+
<li>Return |s|.
1541+
</ol>
1542+
<li>Otherwise:
1543+
<ol>
1544+
<li>If |decls| is not null, prepend it to |rules|.
1545+
<li>For each |rule| in |rules|:
1546+
<ol>
1547+
<li>Append a newline followed by two spaces to |s|.
1548+
<li>Append |rule| to |s|.
1549+
</ol>
1550+
<li>Append a newline followed by RIGHT CURLY BRACKET (U+007D) to |s|.
1551+
<li>Return |s|.
15341552
</ol>
15351553

1536-
15371554
<dt>{{CSSImportRule}}
15381555
<dd>
15391556
The result of concatenating the following:

0 commit comments

Comments
 (0)