diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index f648594db04..7b505779315 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -338,8 +338,7 @@ pub fn matches_compound_selector( where E: Element { - debug_assert_ne!(from_offset, 0); - if cfg!(debug_assertions) { + if cfg!(debug_assertions) && from_offset != 0 { selector.combinator_at_parse_order(from_offset - 1); // This asserts. } diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index 99e42e6d860..359617466d9 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -112,6 +112,10 @@ impl Invalidation { /// Whether this invalidation is effective for the next sibling or /// descendant after us. fn effective_for_next(&self) -> bool { + if self.offset == 0 { + return true; + } + // TODO(emilio): For pseudo-elements this should be mostly false, except // for the weird pseudos in . // @@ -124,6 +128,10 @@ impl Invalidation { } fn kind(&self) -> InvalidationKind { + if self.offset == 0 { + return InvalidationKind::Descendant; + } + if self.selector.combinator_at_parse_order(self.offset - 1).is_ancestor() { InvalidationKind::Descendant } else {