style: Add a CSS error to the console when using non-featureless :host selectors

(which would never match by definition).

Differential Revision: https://phabricator.services.mozilla.com/D111610
This commit is contained in:
Oriol Brufau 2023-05-17 00:28:18 +02:00
parent 7425f2d922
commit 90a2687545
3 changed files with 51 additions and 3 deletions

View file

@ -859,7 +859,7 @@ impl<'a, Impl: 'a + SelectorImpl> SelectorIter<'a, Impl> {
#[inline]
pub(crate) fn is_featureless_host_selector(&mut self) -> bool {
self.selector_length() > 0 &&
self.all(|component| matches!(*component, Component::Host(..))) &&
self.all(|component| component.is_host()) &&
self.next_sequence().is_none()
}
@ -1123,10 +1123,17 @@ pub enum Component<Impl: SelectorImpl> {
impl<Impl: SelectorImpl> Component<Impl> {
/// Returns true if this is a combinator.
#[inline]
pub fn is_combinator(&self) -> bool {
matches!(*self, Component::Combinator(_))
}
/// Returns true if this is a :host() selector.
#[inline]
pub fn is_host(&self) -> bool {
matches!(*self, Component::Host(..))
}
/// Returns the value as a combinator if applicable, None otherwise.
pub fn as_combinator(&self) -> Option<Combinator> {
match *self {