Skip to content

Commit

Permalink
use the correct iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Oct 2, 2023
1 parent 23f3fd5 commit 3612362
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
15 changes: 6 additions & 9 deletions src/main/java/org/htmlunit/html/HtmlForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,12 @@ Collection<SubmittableElement> getSubmittableElements(final SubmittableElement s
if (getPage().getWebClient().getBrowserVersion().hasFeature(FORM_SUBMISSION_FORM_ATTRIBUTE)) {
final String formId = getId();
if (formId != ATTRIBUTE_NOT_DEFINED) {
for (final DomNode domNode : ((HtmlPage) getPage()).getBody().getDescendants()) {
if (domNode instanceof HtmlElement) {
final HtmlElement element = (HtmlElement) domNode;
final String formIdRef = element.getAttribute("form");
if (formId.equals(formIdRef) && isSubmittable(element, submitElement)) {
final SubmittableElement submittable = (SubmittableElement) element;
if (!submittableElements.contains(submittable)) {
submittableElements.add(submittable);
}
for (final HtmlElement element : ((HtmlPage) getPage()).getBody().getHtmlElementDescendants()) {
final String formIdRef = element.getAttribute("form");
if (formId.equals(formIdRef) && isSubmittable(element, submitElement)) {
final SubmittableElement submittable = (SubmittableElement) element;
if (!submittableElements.contains(submittable)) {
submittableElements.add(submittable);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/htmlunit/html/HtmlRadioButtonInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ else if (page != null && page.isHtmlPage()) {
*/
private void setCheckedForPage(final HtmlPage htmlPage) {
final String name = getNameAttribute();
for (final DomNode domNode : htmlPage.getDescendants()) {
if (domNode instanceof HtmlRadioButtonInput) {
final HtmlRadioButtonInput radioInput = (HtmlRadioButtonInput) domNode;
for (final HtmlElement htmlElement : htmlPage.getHtmlElementDescendants()) {
if (htmlElement instanceof HtmlRadioButtonInput) {
final HtmlRadioButtonInput radioInput = (HtmlRadioButtonInput) htmlElement;
if (name.equals(radioInput.getAttribute(DomElement.NAME_ATTRIBUTE))
&& radioInput.getEnclosingForm() == null) {
if (radioInput == this) {
Expand Down Expand Up @@ -308,9 +308,9 @@ public boolean isValueMissingValidityState() {
}

final String name = getNameAttribute();
for (final DomNode domNode : getPage().getDescendants()) {
if (domNode instanceof HtmlRadioButtonInput) {
final HtmlRadioButtonInput radioInput = (HtmlRadioButtonInput) domNode;
for (final HtmlElement htmlElement : getPage().getHtmlElementDescendants()) {
if (htmlElement instanceof HtmlRadioButtonInput) {
final HtmlRadioButtonInput radioInput = (HtmlRadioButtonInput) htmlElement;
if (name.equals(radioInput.getAttribute(DomElement.NAME_ATTRIBUTE))
&& radioInput.isChecked()) {
return false;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/htmlunit/javascript/host/dom/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.htmlunit.html.DomDocumentFragment;
import org.htmlunit.html.DomElement;
import org.htmlunit.html.DomNode;
import org.htmlunit.html.HtmlElement;
import org.htmlunit.html.HtmlInlineFrame;
import org.htmlunit.javascript.configuration.JsxClass;
import org.htmlunit.javascript.configuration.JsxConstant;
Expand Down Expand Up @@ -220,8 +221,8 @@ public Object appendChild(final Object childObject) {
appendedChild = childObject;

initInlineFrameIfNeeded(childDomNode);
for (final DomNode domNode : childDomNode.getDescendants()) {
initInlineFrameIfNeeded(domNode);
for (final HtmlElement htmlElement : childDomNode.getHtmlElementDescendants()) {
initInlineFrameIfNeeded(htmlElement);
}
}
return appendedChild;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ protected boolean isContainedRow(final HtmlTableRow row) {
public Object insertRow(final int index) {
// check if a tbody should be created
if (index != 0) {
for (final DomNode domNode : getDomNodeOrDie().getDescendants()) {
if (domNode instanceof HtmlTableBody
|| domNode instanceof HtmlTableHeader
|| domNode instanceof HtmlTableFooter) {
for (final HtmlElement htmlElement : getDomNodeOrDie().getHtmlElementDescendants()) {
if (htmlElement instanceof HtmlTableBody
|| htmlElement instanceof HtmlTableHeader
|| htmlElement instanceof HtmlTableFooter) {
return super.insertRow(index);
}
}
Expand Down

0 comments on commit 3612362

Please sign in to comment.