Skip to content

Commit f6d45e8

Browse files
Copilotjogibear9988
andcommitted
Preserve CSS rules with empty declaration blocks in stringifier output
Co-authored-by: jogibear9988 <364896+jogibear9988@users.noreply.github.com>
1 parent c12f674 commit f6d45e8

File tree

4 files changed

+27
-1565
lines changed

4 files changed

+27
-1565
lines changed

src/stringify/compiler.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,6 @@ class Compiler {
560560
*/
561561
rule(node: CssRuleAST) {
562562
const decls = node.declarations;
563-
if (!decls.length) {
564-
return '';
565-
}
566563

567564
if (this.compress) {
568565
return (
@@ -574,6 +571,19 @@ class Compiler {
574571
}
575572
const indent = this.indent();
576573

574+
if (!decls.length) {
575+
return (
576+
this.emit(
577+
node.selectors
578+
.map((s) => {
579+
return indent + s;
580+
})
581+
.join(',\n'),
582+
node.position,
583+
) + this.emit(' {}')
584+
);
585+
}
586+
577587
return (
578588
this.emit(
579589
node.selectors

0 commit comments

Comments
 (0)