selectChildren method

Selection selectChildren([
  1. Union2<bool Function(Element, int, HTMLCollection), String>? selector
])

Returns a new selection with the children of each element of the current selection matching the selector.

If no selector is specified, selects all the children. If the selector is specified as a string, selects the children that match (if any). If the selector is a function, it is evaluated for each of the children nodes, in order, being passed the child (child), the child’s index (i), and the list of children (children); the method selects all children for which the selector return truthy.

Implementation

Selection selectChildren(
    [Union2<bool Function(Element, int, HTMLCollection), String>? selector]) {
  return selectAll(
    (selector?.split(
              (match) => childrenFilter(match),
              (selector) => childrenFilter(g.childMatcher(selector)),
            ) ??
            children)
        .u21,
  );
}