match method
Find the objects that have been added via addSelectable
whose css selector is contained in the given css selector.
Implementation
bool match(
CssSelector cssSelector, void Function(CssSelector, T)? matchedCallback) {
var result = false;
var element = cssSelector.element;
var classNames = cssSelector.classNames;
for (var i = 0; i < _listContexts.length; i++) {
_listContexts[i].alreadyMatched = false;
}
result =
_matchTerminal(_elementMap, element, cssSelector, matchedCallback) ||
result;
result = _matchPartial(
_elementPartialMap, element, cssSelector, matchedCallback) ||
result;
for (var index = 0; index < classNames.length; index++) {
var className = classNames[index];
result =
_matchTerminal(_classMap, className, cssSelector, matchedCallback) ||
result;
result = _matchPartial(
_classPartialMap, className, cssSelector, matchedCallback) ||
result;
}
for (var attr in cssSelector.attrs) {
final attrMatchers = _attrMatchers[attr.name];
if (attrMatchers != null) {
for (var pair in attrMatchers) {
if (pair.matcher.matches(attr.value)) {
result =
pair.value.finalize(cssSelector, matchedCallback) || result;
}
}
}
final attrPartialMatchers = _attrPartialMatchers[attr.name];
if (attrPartialMatchers != null) {
for (var pair in attrPartialMatchers) {
if (pair.matcher.matches(attr.value)) {
result = pair.value.match(cssSelector, matchedCallback) || result;
}
}
}
}
return result;
}