selectParentWhere<T extends DOMNode> method

T? selectParentWhere<T extends DOMNode>(
  1. Object? selector
)

Returns a parent T that matches selector.

Implementation

T? selectParentWhere<T extends DOMNode>(Object? selector) {
  if (selector == null) return null;
  bool Function(DOMNode)? nodeSelector = asNodeSelector(selector);
  if (nodeSelector == null) return null;

  DOMNode? node = this;

  while (node != null) {
    if (nodeSelector(node)) return node as T?;
    node = node.parent;
  }
  return null;
}