Skip to content

Find does not search in descendants of matches #189

@BjarkeNL

Description

@BjarkeNL

Thanks for a cool project. Found an issue:

The find() method does not find all matches. After it has found a DOM-node that matches, it seems that it does not keep searching the children of that node for more matches.

Example: (5 b-tags should have been found, but only two are found)

$html = "
    <p>
        <b>
            test
            <b>testing</b>
            <b>This is a test</b>
            <i>italic</i>
            <b>password123</b>
        </b>
        <i><b>another</b></i>
    </p>";

$dom = new Dom();
$dom->loadStr($html);
$nodes = $dom->find('b');
echo count($nodes);

Of course, there is no exact specification in the documentation of how ->find() should work, but it is indicated that it should work like JQuery, so i'm thinking it's not how it was intended. (As an aside: would be nice with documentation of the API)

(The same happens for getElementsByTag() and possibly others)

Version: 2.1.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions