HtmlInput changeType new instance causes side effects
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- JavaScript
- スター
- 952
- フォーク
- 183
- 平均マージ
- 2日 1時間
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
HtmlUnit/htmlunit のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
HtmlUnit/htmlunit の issue をすべて見る
似ている issue
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsオープンep:WebGPU platform:web quantization
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
microsoft/onnxruntime#33752 ·
メンテナーはふだん 2 日以内に返信
-
icon request
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
tabler/tabler-icons#1693 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
alvarotrigo/fullPage.js#4755 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
jlab-sensing/ENTS-backend#854 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
andromarces/agent-loops#1242 ·
メンテナーはふだん 1 日以内に返信