MCPcopy Create free account
hub / github.com/csskit/csskit / specificity

Method specificity

crates/css_ast/src/selector/mod.rs:136–145  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

134
135impl<'a> ToSpecificity for SelectorComponent<'a> {
136 fn specificity(&self) -> Specificity {
137 match self {
138 Self::Id(_) => Specificity(1, 0, 0),
139 Self::Class(_) | Self::Attribute(_) | Self::PseudoClass(_) => Specificity(0, 1, 0),
140 Self::Tag(_) | Self::PseudoElement(_) | Self::LegacyPseudoElement(_) => Specificity(0, 0, 1),
141 Self::FunctionalPseudoElement(_) => Specificity(0, 0, 1),
142 Self::Combinator(_) | Self::Namespace(_) | Self::Wildcard(_) => Specificity(0, 0, 0),
143 Self::FunctionalPseudoClass(f) => f.specificity(),
144 }
145 }
146}
147
148impl<'a> ToSpecificity for CompoundSelector<'a> {

Callers

nothing calls this directly

Calls 4

sumMethod · 0.80
iterMethod · 0.80
into_iterMethod · 0.80
SpecificityClass · 0.50

Tested by

no test coverage detected