-
Notifications
You must be signed in to change notification settings - Fork 135
fix: align DOM checkbox and radio parsing with browsers #99
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For forms that use indexed names like
items[0].selected/items[1].selected, omitting every unchecked checkbox/radio here corrupts the parsed array shape.entriesToObject()compacts indexed paths by encounter order inpackages/core/src/index.ts(setPathValue), so a form where onlyitems[1].selectedis checked now parses asitems[0].selected, attaching the checked state to the wrong row. The previousfalseplaceholder avoided that reindexing, so this is a real data-corruption regression for checkbox/radio-only indexed collections or repeated rows whose only indexed field is a boolean.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked this against the current parser and reproduced it. The outcome is real, but it is not specific to #99: it comes from the existing documented sparse-index compaction rule in @form2js/core, which already compacts any omitted indexed entry (for example, a lone items[1].name also becomes items[0].name). Reintroducing unchecked checkbox placeholders here would undo the browser-aligned DOM behavior we intentionally restored in #99. Follow-up in #100 adds an explicit DOM test for this interaction and documents that omitted unchecked indexed controls do not reserve compacted array slots, so callers that need stable row identity should submit another field for that row.