Closed tkent-google closed 1 year ago
From that discussion, I think there's agreement on adding a second optional argument to address the use cases from @muan et al. If we were to extend FormData
further to support similar initialization to URLSearchParams
we can revisit A vs E vs overloading at that point.
Is it worth also providing a way to pass in the selected edit 2013-01-11 after reading the various specs, it seems like this should be handled implicitly as belowx
/y
coordinate when the submitter is an Image Button? That would allow for full parity with the form submission algorithm (though it would require the developer to capture the coordinate, e.g. via click
handler)
Or alternatively this could be implicitly handled by implementations (i.e. the coordinate would be recorded when the user selects it, and later used when constructing the data set, as is the case with a normal form submission)
Context: https://github.com/whatwg/html/issues/3195 Context: https://github.com/whatwg/xhr/issues/202
FormData should have ability to add an entry for a submitter button when it appends entries for a <form>.
We have multiple options of how to specify submitter. See five comments since https://github.com/whatwg/html/issues/3195#issuecomment-540927844
A)
constructor(optional (HTMLFormElement or record<USVString, FormDataEntryValue>) formOrMap, optional HTMLElement? submitter = null)
Idiomatic.B)
constructor(optional (HTMLElement or record<...>) formOrSubmitterOrMap)
HTMLElement
represents a form or a submitter.C)
constructor(optional (HTMLFormElement or FormDataInit) formOrDict)
The content of the dictionary is idiomatic. Need to wrap a record with a dictionary. Extensible. It's easy to add new members to the dictionary in the future.
D)
constructor(optional (HTMLFormElement or FormDataInit or URLSearchParams) init)
FormData
doesn't supportrecord<>
directly. Developers have to writenew FormData(new URLSearchParams(map))
.E)
constructor(optional HTMLFormElement form, optional HTMLElement? submitter = null)
FormData append(record<USVString, FormDataEntryValue> map);
Developers have to writenew FormData().append(map)
.F) (no changes on the constructor)
Developers have to write
let fd = new FormData().append(form, submitter);
if they want to collect entries including an entry for the submitter.