Remove extra commas in selectors

This commit is contained in:
ConnorSkees 2020-01-26 19:16:26 -05:00
parent 15edae53d6
commit 889488121a
2 changed files with 16 additions and 0 deletions

View File

@ -43,6 +43,17 @@ impl Display for Selector {
} }
} }
} }
SelectorKind::Multiple => {
devour_whitespace(&mut iter);
while let Some(sel) = iter.peek() {
if sel != &&SelectorKind::Multiple {
write!(f, ", ")?;
break;
}
iter.next();
devour_whitespace(&mut iter);
}
}
_ => write!(f, "{}", s)?, _ => write!(f, "{}", s)?,
} }
} }

View File

@ -309,6 +309,11 @@ mod test_selectors {
"$x: oo, ba;\nf#{$x}r {\n baz {\n color: red;\n }\n}\n", "$x: oo, ba;\nf#{$x}r {\n baz {\n color: red;\n }\n}\n",
"foo baz, bar baz {\n color: red;\n}\n" "foo baz, bar baz {\n color: red;\n}\n"
); );
test!(
extra_commas,
"div,, , span, ,, {\n color: red;\n}\n",
"div, span {\n color: red;\n}\n"
);
} }
#[cfg(test)] #[cfg(test)]