Allow multiple semicolons

This commit is contained in:
ConnorSkees 2020-02-29 15:54:13 -05:00
parent 82813fee6f
commit 5367cb315a
2 changed files with 23 additions and 6 deletions

View File

@ -566,8 +566,15 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
toks.next();
devour_whitespace(toks);
// special edge case where there was no space between the colon
// in a style `color:red`. todo: refactor
// in a style, e.g. `color:red`. todo: refactor
let mut v = values.into_iter().peekable();
devour_whitespace(&mut v);
if v.peek().is_none() {
return Ok(Some(Expr::Style(Box::new(Style {
property: String::new(),
value: Value::Null,
}))));
}
let property = Style::parse_property(&mut v, scope, super_selector, String::new())?;
let value = Style::parse_value(&mut v, scope, super_selector)?;
return Ok(Some(Expr::Style(Box::new(Style { property, value }))));

View File

@ -31,8 +31,18 @@ test!(
"$a-b: red; $a_b: green; a {\n color: $a-b;\n}\n",
"a {\n color: green;\n}\n"
);
// test!(
// ends_with_several_semicolons,
// "a {\n color: red;;\n}\n",
// "a {\n color: red;\n}\n"
// );
test!(
two_semicolons,
"a {\n color: red;;\n}\n",
"a {\n color: red;\n}\n"
);
test!(
five_semicolons,
"a {\n color: red;;;;;\n}\n",
"a {\n color: red;\n}\n"
);
test!(
two_semicolons_whitespace,
"a {\n color: red; ;\n}\n",
"a {\n color: red;\n}\n"
);