File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
main/java/org/jsoup/nodes
test/java/org/jsoup/nodes Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -276,9 +276,9 @@ public Elements parents() {
276
276
277
277
private static void accumulateParents (Element el , Elements parents ) {
278
278
Element parent = el .parent ();
279
- if (parent != null && !parent .isNode ("#root" )) {
279
+ while (parent != null && !parent .isNode ("#root" )) {
280
280
parents .add (parent );
281
- accumulateParents ( parent , parents );
281
+ parent = parent . parent ( );
282
282
}
283
283
}
284
284
Original file line number Diff line number Diff line change @@ -256,6 +256,10 @@ public void testGetParents() {
256
256
assertEquals ("div" , parents .get (1 ).tagName ());
257
257
assertEquals ("body" , parents .get (2 ).tagName ());
258
258
assertEquals ("html" , parents .get (3 ).tagName ());
259
+
260
+ Element orphan = new Element ("p" );
261
+ Elements none = orphan .parents ();
262
+ assertEquals (0 , none .size ());
259
263
}
260
264
261
265
@ Test
You can’t perform that action at this time.
0 commit comments