Skip to content

Fix form's named property behavior#1093

Merged
rbri merged 1 commit intoHtmlUnit:masterfrom
duonglaiquang:duong_form
Mar 11, 2026
Merged

Fix form's named property behavior#1093
rbri merged 1 commit intoHtmlUnit:masterfrom
duonglaiquang:duong_form

Conversation

@duonglaiquang
Copy link
Contributor

This PR does the following

Fix form's named property to use past names map per HTML spec.

Problem

The form's named property getter (form.xyz) incorrectly tracks name history on individual elements via the FormFieldWithNameHistory interface. Each form element (input, button, select, etc.) stores its originalName and all newNames, making the element permanently accessible through every name it has ever had.

Per the spec, a form should maintain a past names map at the form level, not on individual elements. The map is populated only when form.xyz resolves to a single element, and entries are invalidated when the element's form owner changes.

Reproducing

// Setup: <form id="f"><input name="foo"></form>

// Rename via form.elements — should NOT register in past names map
f.elements.foo.name = 'bar';
console.log(f.foo); // Expected: undefined — Actual (HtmlUnit): [object HTMLInputElement]
console.log(f.bar === f.foo); // Expected: false — Actual (HtmlUnit): true

@sonarqubecloud
Copy link

@rbri
Copy link
Member

rbri commented Mar 11, 2026

@duonglaiquang thanks a lot

@rbri rbri merged commit f32007a into HtmlUnit:master Mar 11, 2026
8 checks passed
@rbri
Copy link
Member

rbri commented Mar 11, 2026

Have mentioned you as author on all changed files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants