Skip to content

Commit b4bbe47

Browse files
committed
Fix empty :is() when compiling nesting
1 parent e255210 commit b4bbe47

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22607,6 +22607,36 @@ mod tests {
2260722607
})
2260822608
.unwrap();
2260922609
assert_eq!(res.code, ".foo{color:#00f;& .bar{color:red}}");
22610+
22611+
nesting_test_with_targets(
22612+
r#"
22613+
.a {
22614+
&.b,
22615+
&.c {
22616+
&.d {
22617+
color: red;
22618+
}
22619+
}
22620+
}
22621+
"#,
22622+
indoc! {r#"
22623+
.a.b.d {
22624+
color: red;
22625+
}
22626+
22627+
.a.c.d {
22628+
color: red;
22629+
}
22630+
"#},
22631+
Targets {
22632+
browsers: Some(Browsers {
22633+
safari: Some(13 << 16),
22634+
..Browsers::default()
22635+
}),
22636+
include: Features::Nesting,
22637+
exclude: Features::empty(),
22638+
},
22639+
);
2261022640
}
2261122641

2261222642
#[test]

src/rules/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ impl<'i, T: Clone> CssRuleList<'i, T> {
697697
// we need to split the rule in two so we can insert the extra rules in between the declarations from
698698
// the main rule and the nested rules.
699699
let nested_rule = if !style.rules.0.is_empty()
700+
// can happen if there are no compatible rules, above.
701+
&& !style.selectors.0.is_empty()
700702
&& (!logical.is_empty() || !supports.is_empty() || !incompatible_rules.is_empty())
701703
{
702704
let mut rules = CssRuleList(vec![]);

0 commit comments

Comments
 (0)