Enum parcel_selectors::parser::Component
source · pub enum Component<'i, Impl: SelectorImpl<'i>> {
Show 28 variants
Combinator(Combinator),
ExplicitAnyNamespace,
ExplicitNoNamespace,
DefaultNamespace(Impl::NamespaceUrl),
Namespace(Impl::NamespacePrefix, Impl::NamespaceUrl),
ExplicitUniversalType,
LocalName(LocalName<'i, Impl>),
ID(Impl::Identifier),
Class(Impl::Identifier),
AttributeInNoNamespaceExists {
local_name: Impl::LocalName,
local_name_lower: Impl::LocalName,
},
AttributeInNoNamespace {
local_name: Impl::LocalName,
operator: AttrSelectorOperator,
value: Impl::AttrValue,
case_sensitivity: ParsedCaseSensitivity,
never_matches: bool,
},
AttributeOther(Box<AttrSelectorWithOptionalNamespace<'i, Impl>>),
Negation(Box<[Selector<'i, Impl>]>),
Root,
Empty,
Scope,
Nth(NthSelectorData),
NthOf(NthOfSelectorData<'i, Impl>),
NonTSPseudoClass(Impl::NonTSPseudoClass),
Slotted(Selector<'i, Impl>),
Part(Box<[Impl::Identifier]>),
Host(Option<Selector<'i, Impl>>),
Where(Box<[Selector<'i, Impl>]>),
Is(Box<[Selector<'i, Impl>]>),
Any(Impl::VendorPrefix, Box<[Selector<'i, Impl>]>),
Has(Box<[Selector<'i, Impl>]>),
PseudoElement(Impl::PseudoElement),
Nesting,
}
Expand description
A CSS simple selector or combinator. We store both in the same enum for optimal packing and cache performance, see [1].
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1357973
Variants§
Combinator(Combinator)
ExplicitAnyNamespace
ExplicitNoNamespace
DefaultNamespace(Impl::NamespaceUrl)
Namespace(Impl::NamespacePrefix, Impl::NamespaceUrl)
ExplicitUniversalType
LocalName(LocalName<'i, Impl>)
ID(Impl::Identifier)
Class(Impl::Identifier)
AttributeInNoNamespaceExists
AttributeInNoNamespace
AttributeOther(Box<AttrSelectorWithOptionalNamespace<'i, Impl>>)
Negation(Box<[Selector<'i, Impl>]>)
Pseudo-classes
Root
Empty
Scope
Nth(NthSelectorData)
NthOf(NthOfSelectorData<'i, Impl>)
NonTSPseudoClass(Impl::NonTSPseudoClass)
Slotted(Selector<'i, Impl>)
The ::slotted() pseudo-element:
https://drafts.csswg.org/css-scoping/#slotted-pseudo
The selector here is a compound selector, that is, no combinators.
NOTE(emilio): This should support a list of selectors, but as of this writing no other browser does, and that allows them to put ::slotted() in the rule hash, so we do that too.
See https://github.com/w3c/csswg-drafts/issues/2158
Part(Box<[Impl::Identifier]>)
The ::part
pseudo-element.
https://drafts.csswg.org/css-shadow-parts/#part
Host(Option<Selector<'i, Impl>>)
The :host
pseudo-class:
https://drafts.csswg.org/css-scoping/#host-selector
NOTE(emilio): This should support a list of selectors, but as of this writing no other browser does, and that allows them to put :host() in the rule hash, so we do that too.
See https://github.com/w3c/csswg-drafts/issues/2158
Where(Box<[Selector<'i, Impl>]>)
The :where
pseudo-class.
https://drafts.csswg.org/selectors/#zero-matches
The inner argument is conceptually a SelectorList, but we move the selectors to the heap to keep Component small.
Is(Box<[Selector<'i, Impl>]>)
The :is
pseudo-class.
https://drafts.csswg.org/selectors/#matches-pseudo
Same comment as above re. the argument.
Any(Impl::VendorPrefix, Box<[Selector<'i, Impl>]>)
Has(Box<[Selector<'i, Impl>]>)
The :has
pseudo-class.
https://www.w3.org/TR/selectors/#relational
PseudoElement(Impl::PseudoElement)
An implementation-dependent pseudo-element selector.
Nesting
A nesting selector:
https://drafts.csswg.org/css-nesting-1/#nest-selector
NOTE: This is a lightningcss addition.
Implementations§
source§impl<'i, Impl: SelectorImpl<'i>> Component<'i, Impl>
impl<'i, Impl: SelectorImpl<'i>> Component<'i, Impl>
sourcepub fn is_combinator(&self) -> bool
pub fn is_combinator(&self) -> bool
Returns true if this is a combinator.
sourcepub fn as_combinator(&self) -> Option<Combinator>
pub fn as_combinator(&self) -> Option<Combinator>
Returns the value as a combinator if applicable, None otherwise.
sourcepub fn maybe_allowed_after_pseudo_element(&self) -> bool
pub fn maybe_allowed_after_pseudo_element(&self) -> bool
Whether this component is valid after a pseudo-element. Only intended for sanity-checking.