Skip to content

fix: align DOM checkbox and radio parsing with browsers#99

Merged
maxatwork merged 1 commit intomasterfrom
codex/browser-aligned-dom-parsing
Mar 21, 2026
Merged

fix: align DOM checkbox and radio parsing with browsers#99
maxatwork merged 1 commit intomasterfrom
codex/browser-aligned-dom-parsing

Conversation

@maxatwork
Copy link
Owner

@maxatwork maxatwork commented Mar 21, 2026

Summary

  • remove legacy checkbox and radio boolean coercion from
  • update DOM and docs playground tests to assert native browser submission semantics
  • update README and API docs to document omission of unchecked controls and raw string values for checked controls

Test Plan

  • [x]

test
npm run test:packages && npm run test:integration && npm run test:docs


Summary by cubic

Aligns @form2js/dom checkbox and radio parsing with native browser form submission. Removes legacy boolean coercion: checked controls emit their string value; unchecked controls are omitted.

  • Bug Fixes

    • Dropped custom "true"/"false" coercion for checkbox/radio in @form2js/dom.
    • Updated README.md and docs/api.md to reflect browser-aligned behavior.
    • Adjusted DOM and docs playground tests to assert native semantics.
  • Migration

    • If you relied on boolean coercion, cast values in app code (e.g., value === "true").
    • Unchecked controls are no longer included; set defaults explicitly if needed.

Written for commit fc059ef. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

@maxatwork maxatwork merged commit 7494de3 into master Mar 21, 2026
5 checks passed
@maxatwork maxatwork deleted the codex/browser-aligned-dom-parsing branch March 21, 2026 13:44
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc059ef758

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 210 to 214
case "radio":
if (fieldNode.checked && fieldNode.value === "false") {
return false;
}

if (fieldNode.checked && fieldNode.value === "true") {
return true;
}

if (fieldNode.checked) {
return fieldNode.value;
}

return null;

case "checkbox":
if (fieldNode.checked && fieldNode.value === "true") {
return true;
}

if (!fieldNode.checked && fieldNode.value === "true") {
return false;
}

if (fieldNode.checked) {
return fieldNode.value;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve indexed row positions for checkbox/radio fields

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 in packages/core/src/index.ts (setPathValue), so a form where only items[1].selected is checked now parses as items[0].selected, attaching the checked state to the wrong row. The previous false placeholder 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 👍 / 👎.

Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant