Skip to content

Commit

Permalink
more cleanup of froms
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Oct 3, 2023
1 parent c997b87 commit 3ce40a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
8 changes: 7 additions & 1 deletion src/main/java/org/htmlunit/html/HtmlElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,13 @@ protected void checkChildHierarchy(final Node childNode) throws DOMException {
super.checkChildHierarchy(childNode);
}

void setOwningForm(final HtmlForm form) {
/**
* <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
*
* Allows the parser to connect to a form that is not a parent of this due to malformed HTML code
* @param form the owning form
*/
public void setOwningForm(final HtmlForm form) {
owningForm_ = form;
}

Expand Down
23 changes: 0 additions & 23 deletions src/main/java/org/htmlunit/html/HtmlForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ public class HtmlForm extends HtmlElement {

private static final Pattern SUBMIT_CHARSET_PATTERN = Pattern.compile("[ ,].*");

private final List<HtmlElement> lostChildren_ = new ArrayList<>();

private boolean isPreventDefault_;

/**
Expand Down Expand Up @@ -932,27 +930,6 @@ public List<HtmlInput> getInputsByValue(final String value) {
return results;
}

/**
* <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
*
* Allows the parser to notify the form of a field that doesn't belong to its DOM children
* due to malformed HTML code
* @param field the form field
*/
public void addLostChild(final HtmlElement field) {
lostChildren_.add(field);
field.setOwningForm(this);
}

/**
* Gets the form elements that may be submitted but that don't belong to the form's children
* in the DOM due to incorrect HTML code.
* @return the elements
*/
public List<HtmlElement> getLostChildren() {
return lostChildren_;
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ else if (consumingForm_ != null) {
if (newElement instanceof SubmittableElement) {
// Let these be owned by the form
if (((HtmlElement) newElement).getEnclosingForm() != consumingForm_) {
consumingForm_.addLostChild((HtmlElement) newElement);
((HtmlElement) newElement).setOwningForm(consumingForm_);
}
}
}
Expand Down

0 comments on commit 3ce40a9

Please sign in to comment.