resolve issue with @ at-root

This commit is contained in:
ConnorSkees 2020-06-16 22:00:45 -04:00
parent 2cd81ccb0f
commit 5eeee2f01f
4 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,6 @@
# 0.9.1
- fix issue in which `@at-root` would panic when placed after a ruleset
# 0.9.0
This release is focused on setting up the groundwork for implementing `@extend` as well

View File

@ -114,7 +114,8 @@ impl Css {
Stmt::UnknownAtRule {
params, name, body, ..
} => vec![Toplevel::UnknownAtRule { params, name, body }],
Stmt::Return(..) | Stmt::AtRoot { .. } => unreachable!(),
Stmt::Return(..) => unreachable!("@return: {:?}", stmt),
Stmt::AtRoot { .. } => unreachable!("@at-root: {:?}", stmt),
})
}

View File

@ -283,6 +283,7 @@ impl<'a> Parser<'a> {
let body = self.parse_stmt()?;
self.scopes.pop();
self.super_selectors.pop();
self.at_root = self.super_selectors.is_empty();
stmts.push(Stmt::RuleSet {
selector,
body,

View File

@ -63,3 +63,8 @@ test!(
"test {\n @at-root {\n #{&} {\n foo {\n bar: baz;\n }\n }\n }\n}\n",
"test foo {\n bar: baz;\n}\n"
);
test!(
style_before_at_root,
"a {}\n\n@at-root {\n @-ms-viewport { width: device-width; }\n}\n",
"@-ms-viewport {\n width: device-width;\n}\n"
);