From d56100a324ec3d66b77ef937f7f01413fd38ce55 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Fri, 10 Jul 2020 22:24:03 -0400 Subject: [PATCH] correctly parse styles after `@supports` and unknown at rules --- src/parse/mod.rs | 4 ++-- tests/supports.rs | 18 ++++++++++++++++++ tests/unknown-at-rule.rs | 13 +++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/supports.rs diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 59f3cb3..998d6ce 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -546,7 +546,7 @@ impl<'a> Parser<'a> { params.push(tok.kind); } - let raw_body = self.parse()?; + let raw_body = self.parse_stmt()?; let mut rules = Vec::with_capacity(raw_body.len()); let mut body = Vec::new(); @@ -782,7 +782,7 @@ impl<'a> Parser<'a> { extender: self.extender, content_scopes: self.content_scopes, } - .parse()?; + .parse_stmt()?; let mut rules = Vec::with_capacity(raw_body.len()); let mut body = Vec::new(); diff --git a/tests/supports.rs b/tests/supports.rs new file mode 100644 index 0000000..63a888a --- /dev/null +++ b/tests/supports.rs @@ -0,0 +1,18 @@ +#![cfg(test)] + +#[macro_use] +mod macros; + +test!( + style_following, + "@supports (a: b) { + a { + color: red; + } + } + + a { + color: green; + }", + "@supports (a: b) {\n a {\n color: red;\n }\n}\na {\n color: green;\n}\n" +); diff --git a/tests/unknown-at-rule.rs b/tests/unknown-at-rule.rs index 44087c6..c635ba8 100644 --- a/tests/unknown-at-rule.rs +++ b/tests/unknown-at-rule.rs @@ -16,3 +16,16 @@ test!( "@false;\n" ); test!(nothing_after_hash, "@foo #", "@foo #;\n"); +test!( + style_following, + "@foo (a: b) { + a { + color: red; + } + } + + a { + color: green; + }", + "@foo (a: b) {\n a {\n color: red;\n }\n}\na {\n color: green;\n}\n" +);