Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormData should work with all form elements #1258

Closed
LucaMele opened this issue Aug 25, 2019 · 5 comments
Closed

FormData should work with all form elements #1258

LucaMele opened this issue Aug 25, 2019 · 5 comments
Labels
Accepted A feature request or issue is accepted and will be implemented Feature-request Low-prio

Comments

@LucaMele
Copy link
Contributor

LucaMele commented Aug 25, 2019

This code:

const form = document.querySelector('form');
return Object.fromEntries(new FormData(form).entries());

Should always return key/value pairs where key is name of the element and value is the selected value or the inserted text.

At the moment, if a form has datepicker or dropdown it wont serialise it

@markus-walther
Copy link
Contributor

Dropdown and Datepicker do not have ShadowDOM.

Directly constructing onsubmit=".... new FormData(this) ... works in Storybook and has formed the basis for a dropdown form-submission e2e test for some time.

This is therefore tentatively a browser bug.

This code:

const form = document.querySelector('form');
return [...form.elements].filter(element => element.name).map( x => ({name:x.name,value:x.value}))

works and avoids FormData.

@danyball
Copy link
Contributor

danyball commented Nov 8, 2019

@LucaMele can we close this one?

@danyball danyball added the Accepted A feature request or issue is accepted and will be implemented label Jul 10, 2020
@01231
Copy link
Contributor

01231 commented Oct 28, 2020

Closing due to inactivity. Reopen if necessary.

@01231 01231 closed this as completed Oct 28, 2020
@LucaMele
Copy link
Contributor Author

For me this is important. Forms element under WC should behave like forms. We have no shadow dom so as long as we add name everywhere it should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted A feature request or issue is accepted and will be implemented Feature-request Low-prio
Projects
None yet
Development

No branches or pull requests

6 participants