thisOrAncestorMatching<E extends Element> method
Return either this element or the most immediate ancestor of this element
for which the predicate
returns true
, or null
if there is no such
element.
Implementation
@override
E thisOrAncestorMatching<E extends Element>(Predicate<Element> predicate) {
Element? element = this;
while (element != null && !predicate(element)) {
element = element.enclosingElement;
}
return element as E;
}