extra-dom
Version:
Utilities for DOM
15 lines (12 loc) • 315 B
text/typescript
export function findInFollowingSiblingNodes(
node: Node
, predicate: (node: Node) => unknown
): Node | undefined {
const nextNode = node.nextSibling
if (!nextNode) return undefined
if (predicate(nextNode)) {
return nextNode
} else {
return findInFollowingSiblingNodes(nextNode, predicate)
}
}