Skip to content

Commit 3091b66

Browse files
committed
Iterate vs recurse to find the deepest child
Removes chance of overflow in wrap(html) and simplifies. Related to #1864
1 parent 998f429 commit 3091b66

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/org/jsoup/nodes/Node.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,10 @@ public Node wrap(String html) {
449449
}
450450

451451
private Element getDeepChild(Element el) {
452-
List<Element> children = el.children();
453-
if (children.size() > 0)
454-
return getDeepChild(children.get(0));
455-
else
456-
return el;
452+
while (el.childrenSize() > 0) {
453+
el = el.childElementsList().get(0);
454+
}
455+
return el;
457456
}
458457

459458
void nodelistChanged() {

0 commit comments

Comments
 (0)