From 94162af294fd3b4cddd35a9c9bc67e9f06591ba0 Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Mon, 4 Nov 2024 11:02:44 +0100 Subject: [PATCH] one step back to fix the iterator --- src/main/java/org/htmlunit/html/HtmlPage.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/htmlunit/html/HtmlPage.java b/src/main/java/org/htmlunit/html/HtmlPage.java index c1cd1ab341..0a1f9e225f 100644 --- a/src/main/java/org/htmlunit/html/HtmlPage.java +++ b/src/main/java/org/htmlunit/html/HtmlPage.java @@ -1744,10 +1744,14 @@ void notifyNodeAdded(final DomNode node) { if (node instanceof BaseFrameElement) { frameElements_.add((BaseFrameElement) node); } - for (final Iterator iterator - = node.new DescendantElementsIterator<>(BaseFrameElement.class); - iterator.hasNext();) { - frameElements_.add(iterator.next()); + + for (final Iterator iterator + = node.new DescendantElementsIterator<>(HtmlElement.class); + iterator.hasNext();) { + final HtmlElement child = iterator.next(); + if (child instanceof BaseFrameElement) { + frameElements_.add((BaseFrameElement) child); + } } if ("base".equals(node.getNodeName())) {