Open jjatria opened 2 years ago
Came here to +1 this. I factored out "get an element I'm interested into" into a separate function, which returned a subset of the DOM, and calling ->following on the resulting object has either unexpectedly produced nothing or triggered an endless loop spewing out zillions of warning about undefined variables.
Steps to reproduce the behavior
The following works as expected:
However, when storing the DOM in an intermediate variable, the code instead goes into an endless loop when doing a string comparison against an undefined value:
Note that I have only seen this affect calls to
->children
with a selector. If no selector is given, then this error is not triggered:Possible diagnosis
The warning points to the
_root
sub in Mojo::DOM::CSSThe
ne
the warning complains about is the one trying to find the root of the tree, which has gone out of scope. This suggested the following workaround, which does allow the code to behave as expected:Expected behavior
I expected that storing a reference to the DOM after calling
->at
would give me an instance that I could use in the same way as the full DOM, except at a different point in the tree.Actual behavior
Some calls on the intermediate object triggered an endless loop.