Skip to main content

Function: countMatchingChildren()

countMatchingChildren(interactor, container, childSelector, groupSelector?): Promise<number>

Defined in: packages/core/src/drivers/childListHelper.ts:81

Count a container's descendants matching childSelector (see iterateMatchingChildren for the groupSelector recursion that reaches items nested inside wrappers).

The flat case (no groupSelector) is a single Interactor.getElementCount on > childSelector — one round-trip instead of the O(children) exists() position-walk, and count-equivalent to it: the child-combinator + childSelector filter counts exactly the direct children the walk would, still skipping non-matching same-tag siblings. The recursive case must descend into groupSelector wrappers, which no single query expresses, so it keeps walking positions via Interactor.exists (see iterateMatchingChildren for why a getAttribute-based count is not portable).

Parameters​

interactor​

Interactor

container​

PartLocator

childSelector​

string

groupSelector?​

string

Returns​

Promise<number>