& is null inside selectors at root

This commit is contained in:
Connor Skees 2020-08-17 03:13:45 -04:00
parent 3e8b038705
commit 5bcf499942
4 changed files with 18 additions and 2 deletions

View File

@ -77,7 +77,6 @@ impl ContextFlags {
(self.0 & Self::IN_KEYFRAMES) != 0
}
#[allow(dead_code)]
pub fn in_at_root_rule(self) -> bool {
(self.0 & Self::IN_AT_ROOT_RULE) != 0
}

View File

@ -778,7 +778,10 @@ impl<'a> Parser<'a> {
}
'&' => {
let span = self.toks.next().unwrap().pos();
if self.super_selectors.is_empty() && !self.at_root_has_selector && !self.at_root {
if self.super_selectors.is_empty()
&& !self.at_root_has_selector
&& !self.flags.in_at_root_rule()
{
IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Null))
.span(span)
} else {

View File

@ -171,6 +171,15 @@ test!(
/**/ ",
"/**/\n/**/\n/**/\n"
);
test!(
parent_selector_is_null_at_root,
"@if & {
a {
color: red;
}
}",
""
);
error!(
nothing_after_escape,
"@if \\", "Error: Expected expression."

View File

@ -676,6 +676,11 @@ test!(
":a(a , b) {\n color: &;\n}\n",
":a(a , b) {\n color: :a(a , b);\n}\n"
);
test!(
parent_selector_is_null_at_root,
"#{inspect(&)} {\n color: &;\n}\n",
"null {\n color: null;\n}\n"
);
error!(
a_n_plus_b_n_invalid_odd,
":nth-child(ofdd) {\n color: &;\n}\n", "Error: Expected \"odd\"."