specificity property
This selector's specificity.
Specificity is represented in base 1000. The spec says this should be "sufficiently high"; it's extremely unlikely that any single selector sequence will contain 1000 simple selectors.
Implementation
late final int specificity = () {
if (isElement) return 1;
var selector = this.selector;
if (selector == null) return super.specificity;
// https://drafts.csswg.org/selectors/#specificity-rules
switch (normalizedName) {
case 'where':
return 0;
case 'is':
case 'not':
case 'has':
case 'matches':
return selector.components
.map((component) => component.specificity)
.max;
case 'nth-child':
case 'nth-last-child':
return super.specificity +
selector.components.map((component) => component.specificity).max;
default:
return super.specificity;
}
}();