From dc05c8db2dc5041926223548f4c894d6c84ec9dc Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Thu, 9 Jan 2020 21:30:21 -0500 Subject: [PATCH] Handle several nested blocks --- src/css.rs | 1 - src/main.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/css.rs b/src/css.rs index daf236e..169b92a 100644 --- a/src/css.rs +++ b/src/css.rs @@ -93,7 +93,6 @@ impl Css { for rule in rules { self.parse_stmt(rule); } - self.idx -= 1; } } } diff --git a/src/main.rs b/src/main.rs index 9237bd1..0a02755 100644 --- a/src/main.rs +++ b/src/main.rs @@ -459,6 +459,16 @@ mod test_css { ); test!(basic_style, "a {\n color: red;\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!( removes_empty_outer_styles,