Handle several nested blocks

This commit is contained in:
ConnorSkees 2020-01-09 21:30:21 -05:00
parent 31b0ea6b34
commit dc05c8db2d
2 changed files with 10 additions and 1 deletions

View File

@ -93,7 +93,6 @@ impl Css {
for rule in rules { for rule in rules {
self.parse_stmt(rule); self.parse_stmt(rule);
} }
self.idx -= 1;
} }
} }
} }

View File

@ -459,6 +459,16 @@ mod test_css {
); );
test!(basic_style, "a {\n color: red;\n}\n"); test!(basic_style, "a {\n color: red;\n}\n");
test!(two_styles, "a {\n color: red;\n color: blue;\n}\n"); test!(two_styles, "a {\n color: red;\n color: blue;\n}\n");
test!(
two_inner_rulesets,
"a {\n b {\n color: red;\n}\n c {\n color: white;\n}\n}\n",
"a b {\n color: red;\n}\na c {\n color: white;\n}\n"
);
test!(
two_rulesets,
"a {\n color: red;\n}\nc {\n color: white;\n}\n"
);
test!(two_inner_outer_rulesets, "a {\n b {\n color: red;\n}\n c {\n color: white;\n}\n}\na {\n b {\n color: red;\n}\n c {\n color: white;\n}\n}\n", "a b {\n color: red;\n}\na c {\n color: white;\n}\na b {\n color: red;\n}\na c {\n color: white;\n}\n");
test!(selector_mul, "a, b {\n color: red;\n}\n"); test!(selector_mul, "a, b {\n color: red;\n}\n");
test!( test!(
removes_empty_outer_styles, removes_empty_outer_styles,