Skip to content

Commit

Permalink
Iterate vs recurse to find the deepest child
Browse files Browse the repository at this point in the history
Removes chance of overflow in wrap(html) and simplifies.

Related to #1864
  • Loading branch information
jhy committed Jan 23, 2023
1 parent 998f429 commit 3091b66
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/org/jsoup/nodes/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,10 @@ public Node wrap(String html) {
}

private Element getDeepChild(Element el) {
List<Element> children = el.children();
if (children.size() > 0)
return getDeepChild(children.get(0));
else
return el;
while (el.childrenSize() > 0) {
el = el.childElementsList().get(0);
}
return el;
}

void nodelistChanged() {
Expand Down

0 comments on commit 3091b66

Please sign in to comment.