diff options
Diffstat (limited to 'components/selectors/matching.rs')
-rw-r--r-- | components/selectors/matching.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index d8d083d7b28..7c509e8e673 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -410,6 +410,7 @@ fn next_element_for_combinator<E>( element: &E, combinator: Combinator, selector: &SelectorIter<E::Impl>, + context: &MatchingContext<E::Impl>, ) -> Option<E> where E: Element, @@ -450,11 +451,20 @@ where }, Combinator::SlotAssignment => { debug_assert!( + context.current_host.is_some(), + "Should not be trying to match slotted rules in a non-shadow-tree context" + ); + debug_assert!( element .assigned_slot() .map_or(true, |s| s.is_html_slot_element()) ); - element.assigned_slot() + let scope = context.current_host?; + let mut current_slot = element.assigned_slot()?; + while current_slot.containing_shadow_host().unwrap().opaque() != scope { + current_slot = current_slot.assigned_slot()?; + } + Some(current_slot) }, Combinator::PseudoElement => element.pseudo_element_originating_element(), } @@ -511,7 +521,8 @@ where Combinator::PseudoElement => SelectorMatchingResult::NotMatchedGlobally, }; - let mut next_element = next_element_for_combinator(element, combinator, &selector_iter); + let mut next_element = + next_element_for_combinator(element, combinator, &selector_iter, &context); // Stop matching :visited as soon as we find a link, or a combinator for // something that isn't an ancestor. @@ -575,7 +586,7 @@ where visited_handling = VisitedHandlingMode::AllLinksUnvisited; } - next_element = next_element_for_combinator(&element, combinator, &selector_iter); + next_element = next_element_for_combinator(&element, combinator, &selector_iter, &context); } } |