You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When constructing a FormData instance from a HTMLFormElement containing a button with a name and value, that button's value is always included in the resulting FormData.
This isn't the case for any browser I've tested (Chromium, Firefox, WebKit). A submit button's value is only included in form submissions when that button is the one that triggered the form submission, so it makes sense to exclude button values by default.
The XMLHttpRequest Spec defines an optional submitter parameter that can be used to include a submit button's value in the resulting form data instead.
To Reproduce
describe('FormData',()=>{describe('Constructor',()=>{it('Only includes button values when they are passed in as submitter',()=>{constform=document.createElement('form');constinput=document.createElement('input');constbutton=document.createElement('button');input.name='input';input.value='testing';button.name='button';button.value='buttonValue';form.append(input);form.append(button);constformDataWithoutButton=newwindow.FormData(form);constformDataWithButton=newwindow.FormData(form,button);expect(formDataWithoutButton.get('input')).toBe('testing');expect(formDataWithoutButton.get('button')).toBeNull();expect(formDataWithButton.get('input')).toBe('testing');expect(formDataWithoutButton.get('button')).toBe('buttonValue');});});});
Expected behavior
Constructing a new FormData instance from the form without passing in the button as submitter shouldn't include the button's value.
Additionally it would be nice if the submitter parameter could be supported by happy-dom.
Device:
OS: [e.g. iOS]
Browser [e.g. chrome, safari]
Version [e.g. 22]
Additional context
Looks like the submitter parameter has been in the spec since the end of January 2023 (ref), and implemented in most major browsers since April 2023.
FWIW jsdom doesn't support the submitter parameter either, but it does exclude button values by default.
The text was updated successfully, but these errors were encountered:
FYI jsdom has supported submittersince 22.1.0, but it looks like most people are still using 20.0.3 since the latest jest-environment-jsdom wants ^20.0.0
karpiuMG
added a commit
to karpiuMG/happy-dom
that referenced
this issue
Mar 1, 2025
Describe the bug
When constructing a
FormData
instance from aHTMLFormElement
containing a button with aname
andvalue
, that button's value is always included in the resultingFormData
.This isn't the case for any browser I've tested (Chromium, Firefox, WebKit). A submit button's value is only included in form submissions when that button is the one that triggered the form submission, so it makes sense to exclude button values by default.
The XMLHttpRequest Spec defines an optional
submitter
parameter that can be used to include a submit button's value in the resulting form data instead.To Reproduce
Expected behavior
Constructing a new FormData instance from the form without passing in the button as submitter shouldn't include the
button
's value.Additionally it would be nice if the
submitter
parameter could be supported by happy-dom.Device:
Additional context
Looks like the
submitter
parameter has been in the spec since the end of January 2023 (ref), and implemented in most major browsers since April 2023.FWIW jsdom doesn't support the
submitter
parameter either, but it does exclude button values by default.The text was updated successfully, but these errors were encountered: