As far as I understand, find is supposed to search only in descendants of the current node. However, find actually searches most nodes in the document:
auto doc = createDocument("<html>
<body>
<div id=\"a1\">
<div id=\"b1\">
<div id=\"c1\"></div>
<div id=\"c2\"></div>
</div>
<div id=\"b2\"></div>
</div>
<div id=\"a2\"></div>
</body></html>");
auto elem = doc.querySelector("#c1");
writeln(elem.id); //c1
writeln(elem.find("div")); //[<div id="c1"/>, <div id="c2"/>, <div id="b2"/>, <div id="a2"/>]
To prevent find from scanning ancestors the popFront function in DescendantsDFForward needs to be fixed:
if (parent /*&& (top_ != parent)*/) //FIX in commented code
next = parent.next_;
However, even with this find will still search siblings (c1 and c2). Is this the expected behaviour? DescendantsDFForward explicitly sets top_ = first.parent_ but I think it'd be more intuitive if find only searched descendants.
As far as I understand, find is supposed to search only in descendants of the current node. However, find actually searches most nodes in the document:
To prevent find from scanning ancestors the
popFrontfunction inDescendantsDFForwardneeds to be fixed:However, even with this find will still search siblings (c1 and c2). Is this the expected behaviour?
DescendantsDFForwardexplicitly setstop_ = first.parent_but I think it'd be more intuitive if find only searched descendants.