matchedRules method
Implementation
List<CSSRule> matchedRules(RuleSet ruleSet, Element element) {
List<CSSRule> matchedRules = [];
if (ruleSet.isEmpty) {
return matchedRules;
}
// #id
String? id = element.id;
if (id != null) {
matchedRules.addAll(_collectMatchingRulesForList(ruleSet.idRules[id], element));
}
// .class
for (String className in element.classList) {
matchedRules.addAll(_collectMatchingRulesForList(ruleSet.classRules[className], element));
}
// attribute selector
for (String attribute in element.attributes.keys) {
matchedRules.addAll(_collectMatchingRulesForList(ruleSet.attributeRules[attribute.toUpperCase()], element));
}
// tag
matchedRules.addAll(_collectMatchingRulesForList(ruleSet.tagRules[element.tagName], element));
// universal
matchedRules.addAll(_collectMatchingRulesForList(ruleSet.universalRules, element));
return matchedRules;
}