In one of the previous versions a breaking change with HtmlInput.setAttribute
was introduced.
Currently, when changing type
of HtmlInput
a new instance is created and the instance worked on is no longer attached.
Looks like this behavior is intended but causes undesired side effects as the user has absolutely no way knowing they are working on a stale object.
(HtmlElementBuilder
is a helper class we created, it basically just creates a StringWebResponse
and passes it to to PageCreator
)
Example 1 :
@Test
public void testInput() {
HtmlPage page = HtmlElementBuilder.createPageFromString("<html><head></head><body></body></html>");
HtmlElement input = (HtmlElement) page.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "test");
page.getBody().appendChild(input);
System.out.println(page.asXml());
}
Which result in this result:
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head/>
<body>
<input type="hidden"/>
</body>
</html>
Another case:
@Test
public void testInput() {
HtmlPage page = HtmlElementBuilder.createPageFromString("<html><head></head><body></body></html>");
HtmlElement input = (HtmlElement) page.createElement("input");
page.getBody().appendChild(input);
input.setAttribute("type", "hidden");
input.setAttribute("name", "test");
System.out.println(page.asXml());
}
Results in:
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head/>
<body>
<input type="hidden"/>
</body>
</html>
There are workarounds for this but this feels very error prone.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too