Skip to content

Commit 5cd3c91

Browse files
committed
[css-nesting-1] Add serialization rules, copying from CSSOM.
1 parent df214d1 commit 5cd3c91

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

css-nesting-1/Overview.bs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,4 +747,33 @@ invoking [=insert a CSS rule=] <var>rule</var>
747747
into the [=CSSRule/child CSS rules=] at <var>index</var>.
748748

749749
The <dfn method for=CSSNestingRule>deleteRule(<var>index</var>)</dfn> method
750-
must [=remove a CSS rule=] from the [=CSSRule/child CSS rules=] at <var>index</var>.
750+
must [=remove a CSS rule=] from the [=CSSRule/child CSS rules=] at <var>index</var>.
751+
752+
To serialize a {{CSSNestingRule}}:
753+
return the result of the following steps:
754+
755+
<ol>
756+
<li>Let |s| initially be the string "<code>@nest</code>" followed by a single SPACE (U+0020).
757+
<li>Append to |s| the result of performing <a>serialize a group of selectors</a> on the rule's associated selectors,
758+
followed by the string "<code> {</code>", i.e., a single SPACE (U+0020), followed by LEFT CURLY BRACKET (U+007B).
759+
<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.
760+
<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.
761+
<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|.
762+
<li>If |rules| is null:
763+
<ol>
764+
<li>Append a single SPACE (U+0020) to |s|
765+
<li>Append |decls| to |s|
766+
<li>Append " }" to |s| (i.e. a single SPACE (U+0020) followed by RIGHT CURLY BRACKET (U+007D)).
767+
<li>Return |s|.
768+
</ol>
769+
<li>Otherwise:
770+
<ol>
771+
<li>If |decls| is not null, prepend it to |rules|.
772+
<li>For each |rule| in |rules|:
773+
<ol>
774+
<li>Append a newline followed by two spaces to |s|.
775+
<li>Append |rule| to |s|.
776+
</ol>
777+
<li>Append a newline followed by RIGHT CURLY BRACKET (U+007D) to |s|.
778+
<li>Return |s|.
779+
</ol>

0 commit comments

Comments
 (0)