Devour whitespace after {

This commit is contained in:
ConnorSkees 2020-02-02 18:01:09 -05:00
parent 231252a9d9
commit 4263fd2532
3 changed files with 10 additions and 7 deletions

View File

@ -50,6 +50,8 @@ impl Mixin {
_ => return Err((pos, String::from("expected `(` or `{`"))),
};
devour_whitespace(toks);
let mut nesting = 1;
let mut body = Vec::new();

View File

@ -127,12 +127,7 @@ impl Display for SelectorKind {
SelectorKind::Attribute(attr) => write!(f, "{}", attr),
SelectorKind::Pseudo(s) => write!(f, ":{}", s),
SelectorKind::PseudoElement(s) => write!(f, "::{}", s),
SelectorKind::PseudoParen(s, val) => write!(
f,
":{}({})",
s,
val
),
SelectorKind::PseudoParen(s, val) => write!(f, ":{}({})", s, val),
SelectorKind::Super | SelectorKind::None | SelectorKind::InterpolatedSuper => {
write!(f, "")
}
@ -239,7 +234,8 @@ impl<'a> SelectorParser<'a> {
toks.push(' ');
}
}
self.selectors.push(SelectorKind::PseudoParen(s, toks.trim_end().to_owned()))
self.selectors
.push(SelectorKind::PseudoParen(s, toks.trim_end().to_owned()))
} else {
self.selectors.push(SelectorKind::Pseudo(s))
}

View File

@ -9,6 +9,11 @@ test!(
"b {\n color: red;\n}\n"
);
test!(empty_mixin, "@mixin a {}\n\nb {\n @include a;\n}\n", "");
test!(
just_a_comment,
"@mixin foo() {\n /* begin foo */\n}\n\na {\n @include foo();\n}\n",
"a {\n /* begin foo */\n}\n"
);
test!(
mixin_two_styles,
"@mixin a {\n color: red;\n color: blue;\n}\n\nb {\n @include a;\n}\n",