support @at-root inside media query inside style rule

This commit is contained in:
Connor Skees 2021-07-28 02:08:20 -04:00
parent 63567da749
commit d07c1d3a06
3 changed files with 28 additions and 2 deletions

View File

@ -29,7 +29,7 @@ That said, there are a number of known missing features and bugs. The notable fe
```
indented syntax
@forward and more complex uses of @use
complex uses of @at-root
media queries with @at-root
@media query merging
media queries with @import
/ as a separator in color functions, e.g. rgba(255, 255, 255 / 0)

View File

@ -327,7 +327,13 @@ impl Css {
}))]
}
Stmt::Return(..) => unreachable!("@return: {:?}", stmt),
Stmt::AtRoot { .. } => unreachable!("@at-root: {:?}", stmt),
Stmt::AtRoot { body } => body
.into_iter()
.map(|r| self.parse_stmt(r))
.collect::<SassResult<Vec<Vec<Toplevel>>>>()?
.into_iter()
.flatten()
.collect(),
Stmt::Keyframes(k) => vec![Toplevel::Keyframes(k)],
Stmt::KeyframesRuleSet(k) => {
let KeyframesRuleSet { body, selector } = *k;

View File

@ -107,6 +107,26 @@ test!(
}",
"a {\n color: red;\n}\n\na {\n color: red;\n}\n"
);
test!(
at_root_inside_media,
"@media screen {
@at-root a {
color: red;
}
}",
"@media screen {\n a {\n color: red;\n }\n}\n"
);
test!(
at_root_inside_media_inside_style_rule,
"b {
@media screen {
@at-root a {
color: red;
}
}
}",
"@media screen {\n a {\n color: red;\n }\n}\n"
);
error!(
#[ignore = "we do not currently validate missing closing curly braces"]
missing_closing_curly_brace,