thisOrAncestorMatching3<E extends Element> method

  1. @override
E? thisOrAncestorMatching3<E extends Element>(
  1. bool predicate(
    1. Element
    )
)
inherited

Returns 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? thisOrAncestorMatching3<E extends Element>(
  bool Function(Element) predicate,
) {
  Element? element = this;
  while (element != null && !predicate(element)) {
    element = (element as ElementImpl).enclosingElement3;
  }
  return element as E?;
}