correctly parse styles after @supports and unknown at rules

This commit is contained in:
Connor Skees 2020-07-10 22:24:03 -04:00
parent b4bdd2f926
commit d56100a324
3 changed files with 33 additions and 2 deletions

View File

@ -546,7 +546,7 @@ impl<'a> Parser<'a> {
params.push(tok.kind); 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 rules = Vec::with_capacity(raw_body.len());
let mut body = Vec::new(); let mut body = Vec::new();
@ -782,7 +782,7 @@ impl<'a> Parser<'a> {
extender: self.extender, extender: self.extender,
content_scopes: self.content_scopes, content_scopes: self.content_scopes,
} }
.parse()?; .parse_stmt()?;
let mut rules = Vec::with_capacity(raw_body.len()); let mut rules = Vec::with_capacity(raw_body.len());
let mut body = Vec::new(); let mut body = Vec::new();

18
tests/supports.rs Normal file
View File

@ -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"
);

View File

@ -16,3 +16,16 @@ test!(
"@false;\n" "@false;\n"
); );
test!(nothing_after_hash, "@foo #", "@foo #;\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"
);