Skip to content

Commit

Permalink
[cssom] Don't serialize empty rules
Browse files Browse the repository at this point in the history
With CSSOM, it's possible to reach into a CSSNestedDeclarations
rule and remove its declarations, causing it to serialize
as the empty string. Such rules add "whitespace junk" when
serializing the outer rule, which looks unattractive.

Fixed by ignoring rules that serialize to the empty string.
  • Loading branch information
Anders Hartvoll Ruud authored and emilio committed Oct 1, 2024
1 parent 065b17d commit 5f1b63c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cssom-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1709,10 +1709,14 @@ To <dfn export>serialize a CSS rule</dfn>, perform one of the following in accor
<ol>
<li>If |decls| is not null, prepend it to |rules|.
<li>For each |rule| in |rules|:
<ol>
<li>Append a newline followed by two spaces to |s|.
<li>Append |rule| to |s|.
</ol>
<ul>
<li>If |rule| is the empty string, do nothing.
<li>Otherwise:
<ol>
<li>Append a newline followed by two spaces to |s|.
<li>Append |rule| to |s|.
</ol>
</ul>
<li>Append a newline followed by RIGHT CURLY BRACKET (U+007D) to |s|.
<li>Return |s|.
</ol>
Expand Down

0 comments on commit 5f1b63c

Please sign in to comment.