Function findOne

  • Finds one element in a tree that passes a test.

    Parameters

    • test: ((elem: Element) => boolean)

      Function to test nodes on.

        • (elem): boolean
        • Parameters

          • elem: Element

          Returns boolean

    • nodes: AnyNode[]

      Node or array of nodes to search.

    • recurse: boolean = true

      Also consider child nodes.

    Returns Element | null

    The first node that passes test.