Skip to content

Commit 8652701

Browse files
committed
Use :is for non-leading nesting with multiple compound selectors
1 parent d35279e commit 8652701

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18891,7 +18891,7 @@ mod tests {
1889118891
}
1889218892
"#,
1889318893
indoc! {r#"
18894-
.baz .foo .bar {
18894+
.baz :is(.foo .bar) {
1889518895
background: green;
1889618896
}
1889718897
"#},

src/selector.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ where
966966
let mut combinators = selector.iter_raw_match_order().rev().filter_map(|x| x.as_combinator());
967967
let compound_selectors = selector.iter_raw_match_order().as_slice().split(|x| x.is_combinator()).rev();
968968

969+
let mut first = true;
969970
let mut combinators_exhausted = false;
970971
for mut compound in compound_selectors {
971972
debug_assert!(!combinators_exhausted);
@@ -984,8 +985,9 @@ where
984985
continue;
985986
}
986987

987-
let has_leading_nesting = matches!(compound[0], Component::Nesting);
988+
let has_leading_nesting = first && matches!(compound[0], Component::Nesting);
988989
let first_index = if has_leading_nesting { 1 } else { 0 };
990+
first = false;
989991

990992
// 1. If there is only one simple selector in the compound selectors
991993
// which is a universal selector, append the result of

0 commit comments

Comments
 (0)