Skip to content

fix: [#2356] Ignore null and undefined when setting input.files - #2361

Open
mixelburg wants to merge 2 commits into
capricorn86:masterfrom
mixelburg:fix-input-files-null
Open

fix: [#2356] Ignore null and undefined when setting input.files#2361
mixelburg wants to merge 2 commits into
capricorn86:masterfrom
mixelburg:fix-input-files-null

Conversation

@mixelburg

Copy link
Copy Markdown
Contributor

Setting input.files = null (or undefined) on a file input is stored as-is, so reading .value afterwards throws. Per spec these assignments are no-ops, and browsers keep the existing FileList — this also matches jsdom, which ignores the write when the input isn't a file type.

The setter now returns early for null/undefined and for non-file inputs. Added tests covering both cases.

Closes #2356

@mixelburg

Copy link
Copy Markdown
Contributor Author

Hi! The build (20) failure here looks unrelated to this change — it's in @happy-dom/server-renderer (ServerRendererBrowser.test.ts / ServerRendererPage.test.ts), specifically the timing-sensitive waitUntilComplete() tests: "2 tasks did not end in time" vs the expected "1 task", plus a null .error in the debug-error case. This PR only touches the HTMLInputElement.files setter and its tests.

The sibling PR #2362 ran the same server-renderer tests on Node 20 the same day and passed, which points to a flake rather than a real regression. Would you mind re-running the build (20) job? Happy to dig in further if it turns out not to be a flake.

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.

HTMLInputElement.files = null breaks .value getter on file inputs

1 participant