do not emit empty media queries

This commit is contained in:
ConnorSkees 2020-04-21 04:52:47 -04:00
parent 11cc99e877
commit 1cb135c833
2 changed files with 4 additions and 0 deletions

View File

@ -155,6 +155,9 @@ impl Css {
} }
Toplevel::AtRule(r) => match r { Toplevel::AtRule(r) => match r {
AtRule::Unknown(u) => { AtRule::Unknown(u) => {
if u.body.is_empty() {
continue;
}
if u.params.is_empty() { if u.params.is_empty() {
writeln!(buf, "{}@{} {{", padding, u.name)?; writeln!(buf, "{}@{} {{", padding, u.name)?;
} else { } else {

View File

@ -21,3 +21,4 @@ test!(
"@foo {\n a {\n color: red;\n }\n}\n" "@foo {\n a {\n color: red;\n }\n}\n"
); );
test!(unknown_at_rule_no_selector, "@foo {\n color: red;\n}\n"); test!(unknown_at_rule_no_selector, "@foo {\n color: red;\n}\n");
test!(empty, "@media (min-width: 2px) {}", "");