fix: append array items individually to FormData for custom elements outside forms - #3963
Open
AndrewGit25 wants to merge 2 commits into
Open
fix: append array items individually to FormData for custom elements outside forms#3963AndrewGit25 wants to merge 2 commits into
AndrewGit25 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resolves an issue where elements outside
<form>elements with .value returning an array (e.g., custom elements / web components) were joined as comma-separated string values (fruit=banana,apple) instead of appended as distinct entries (fruit=banana&fruit=apple).Updates
shouldIncludeto checkgetRawAttribute(elt, 'name')for elements without a DOM .name property.Converts array values in
getValueFromInputsoaddValueToFormDataappends array elements individually.Includes unit tests in test/core/parameters.js.
Corresponding issue: N/A
Testing
Added unit test in test/core/parameters.js to verify that custom elements returning an array for .value append each item individually to FormData. Verified locally by running npm test, which runs linting (eslint), TypeScript type checks (tsc), and browser suite (web-test-runner on Chromium). All 848 tests passed.
Ran a test in scratchpad with a
<custom-select>and successfully submitted formdata of name and value for each item in array. And no formdata was submitted without a name attribute. This is mirroring native<select multiple>behavior.Checklist
masterfor website changes,devforsource changes)
approved via an issue
npm run test) and verified that it succeeded