HtmlInput changeType new instance causes side effects
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 38/100
Hướng nghiên cứu
Start by tracing how HtmlInput.setAttribute handles changes to type and how the replacement instance is attached to its page. Use the two testInput examples in the issue as regression cases, checking the serialized page output with page.asXml(). Done means setting type and then name preserves both attributes whether the input is appended before or after the type change.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 952
- Fork
- 183
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của HtmlUnit/htmlunit
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Tất cả issue của HtmlUnit/htmlunit
Issue tương tự
-
[guide] AGENTS.md claims the coverage gate, e2e and full lint run on every PR after ADR 0011 focused validationCó thể đã có người làm @hivecommons-hive đã nhận hôm nay. Đang mởagent/guide documentation hive/claimed-by-guide stage/040-covered-by-pr
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 81/100
cncf/endusers#2006 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
check:passed feeds:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
all-contributors/cli#587 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
RGAA5
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 8 ngày
-
feedback simulation workshop
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
githubnext/gh-aw-workshop#5157 ·
Maintainer thường phản hồi trong vòng 1 ngày