mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Cleanup selector-matching for nested pseudo-elements, match ::slotted correctly when there's no selector before it, and add tests.
D29542 fixed the bogus checks that was making nested pseudo-elements match author rules. This adds tests and ends up being just a cleanup, though as it turns out we it also fixes an issue with ::slotted() matched from Element.matches. Differential Revision: https://phabricator.services.mozilla.com/D27529
This commit is contained in:
parent
272d9758d7
commit
43444db8a8
9 changed files with 35 additions and 38 deletions
|
@ -2002,9 +2002,7 @@ where
|
|||
},
|
||||
SimpleSelectorParseResult::SlottedPseudo(selector) => {
|
||||
state.insert(SelectorParsingState::AFTER_SLOTTED);
|
||||
if !builder.is_empty() {
|
||||
builder.push_combinator(Combinator::SlotAssignment);
|
||||
}
|
||||
builder.push_combinator(Combinator::SlotAssignment);
|
||||
builder.push_simple_selector(Component::Slotted(selector));
|
||||
},
|
||||
SimpleSelectorParseResult::PseudoElement(p) => {
|
||||
|
@ -2012,9 +2010,7 @@ where
|
|||
if !p.accepts_state_pseudo_classes() {
|
||||
state.insert(SelectorParsingState::AFTER_NON_STATEFUL_PSEUDO_ELEMENT);
|
||||
}
|
||||
if !builder.is_empty() {
|
||||
builder.push_combinator(Combinator::PseudoElement);
|
||||
}
|
||||
builder.push_combinator(Combinator::PseudoElement);
|
||||
builder.push_simple_selector(Component::PseudoElement(p));
|
||||
},
|
||||
}
|
||||
|
@ -2828,7 +2824,10 @@ pub mod tests {
|
|||
assert_eq!(
|
||||
parse("::before"),
|
||||
Ok(SelectorList::from_vec(vec![Selector::from_vec(
|
||||
vec![Component::PseudoElement(PseudoElement::Before)],
|
||||
vec![
|
||||
Component::Combinator(Combinator::PseudoElement),
|
||||
Component::PseudoElement(PseudoElement::Before),
|
||||
],
|
||||
specificity(0, 0, 1) | HAS_PSEUDO_BIT,
|
||||
)]))
|
||||
);
|
||||
|
@ -2836,6 +2835,7 @@ pub mod tests {
|
|||
parse("::before:hover"),
|
||||
Ok(SelectorList::from_vec(vec![Selector::from_vec(
|
||||
vec![
|
||||
Component::Combinator(Combinator::PseudoElement),
|
||||
Component::PseudoElement(PseudoElement::Before),
|
||||
Component::NonTSPseudoClass(PseudoClass::Hover),
|
||||
],
|
||||
|
@ -2846,6 +2846,7 @@ pub mod tests {
|
|||
parse("::before:hover:hover"),
|
||||
Ok(SelectorList::from_vec(vec![Selector::from_vec(
|
||||
vec![
|
||||
Component::Combinator(Combinator::PseudoElement),
|
||||
Component::PseudoElement(PseudoElement::Before),
|
||||
Component::NonTSPseudoClass(PseudoClass::Hover),
|
||||
Component::NonTSPseudoClass(PseudoClass::Hover),
|
||||
|
@ -2958,6 +2959,7 @@ pub mod tests {
|
|||
specificity(0, 0, 0),
|
||||
)]))
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
parse_ns(":not(svg|*)", &parser),
|
||||
Ok(SelectorList::from_vec(vec![Selector::from_vec(
|
||||
|
@ -3032,6 +3034,8 @@ pub mod tests {
|
|||
Some(&Component::PseudoElement(PseudoElement::Before))
|
||||
);
|
||||
assert_eq!(iter.next(), None);
|
||||
assert_eq!(iter.next_sequence(), Some(Combinator::PseudoElement));
|
||||
assert_eq!(iter.next(), None);
|
||||
assert_eq!(iter.next_sequence(), None);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue