[BUG] Children of a DocElement from a relaxed Doc should also be relaxed.
danisty opened this issue · 2 comments
danisty commented
Describe the bug
Getting the children
of a Doc/DocElement will call the public constructor of DocElement and set relaxed
to false, thus making all children throw an exception if a query selection fails.
Also happens for siblings
, allElements
and parents
.
Code Sample
val doc = htmlDocument("<div>skrape<b>it</b></div>")
doc.relaxed = true
doc.findFirst("b").findFirst("a") // Will not throw an exception
doc.children[0].findFirst("a") // Will throw an exception
// it.skrape.selects.ElementNotFoundException: Could not find element "a"
Expected behavior
Inherit the relaxed property.
danisty commented
I'd like to reopen this issue since the merged pr doesn't fix it. The relaxed
property should be passed to the DocElement constructor for the methods mentioned before: children
, siblings
, allElements
and parents
.
christian-draeger commented
Ok thanks for pointing this out 👍