Skip to content

Commit

Permalink
Fix empty :is() when compiling nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Nov 7, 2023
1 parent e255210 commit b4bbe47
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22607,6 +22607,36 @@ mod tests {
})
.unwrap();
assert_eq!(res.code, ".foo{color:#00f;& .bar{color:red}}");

nesting_test_with_targets(
r#"
.a {
&.b,
&.c {
&.d {
color: red;
}
}
}
"#,
indoc! {r#"
.a.b.d {
color: red;
}

.a.c.d {
color: red;
}
"#},
Targets {
browsers: Some(Browsers {
safari: Some(13 << 16),
..Browsers::default()
}),
include: Features::Nesting,
exclude: Features::empty(),
},
);
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ impl<'i, T: Clone> CssRuleList<'i, T> {
// we need to split the rule in two so we can insert the extra rules in between the declarations from
// the main rule and the nested rules.
let nested_rule = if !style.rules.0.is_empty()
// can happen if there are no compatible rules, above.
&& !style.selectors.0.is_empty()
&& (!logical.is_empty() || !supports.is_empty() || !incompatible_rules.is_empty())
{
let mut rules = CssRuleList(vec![]);
Expand Down

0 comments on commit b4bbe47

Please sign in to comment.