Skip to content

Include form-associated custom elements in form submissions - #807

Merged
triskweline merged 2 commits into
unpoly:masterfrom
kmmbvnr:fix/web-component-formdata
Sep 13, 2026
Merged

triskweline merged 2 commits into
unpoly:masterfrom
kmmbvnr:fix/web-component-formdata

Conversation

@kmmbvnr

@kmmbvnr kmmbvnr commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

This pull request fixes the original issue #593.

I develop Viewflow.io and am evaluating alternatives to Turbolinks, Hotwire/Turbo, and htmx. During that work, I found a discrepancy in Unpoly. An [up-submit] form dropped values from form-associated custom elements. A normal browser submission included them.

What changes

up.Params.fromForm() now begins with native FormData(form). It uses the browser's form-data construction algorithm. This includes form-associated custom elements and values appended by formdata listeners.

The method then adds configured Unpoly fields that are absent from form.elements. This keeps up.form.config.fieldSelectors working for non-native controls. It does not duplicate native or form-associated controls.

This is a small submission-only change. It does not change up.Params.fromContainer() or Unpoly's watcher behavior.

Compatibility

Existing native controls keep browser submission semantics. Configured custom controls still submit when they expose name, value, and disabled properties.

Verification

  • I added specs for formdata listeners, form-associated custom elements, and configured non-native controls.
  • I ran npm run lint, npm run build-ci, and the focused Chrome up.Params suite.

Authorship

This PR was AI-assisted and made with Codex Terra. I reviewed every line and take responsibility for the code.

@triskweline
triskweline merged commit 8213239 into unpoly:master Sep 13, 2026
6 checks passed
@triskweline

Copy link
Copy Markdown
Contributor

Thanks @kmmbvnr.

It turned out there was a lot of follow-up work necessary for form-associated custom elements to function outside of the submission, especially for reactive server forms. This has now been implemented in master.

@kmmbvnr

kmmbvnr commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Great! The things that I like in Unpoly that it's batteries included. Currently I have to have a lot of user side code to handle forms reactivity

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.

Web Component form field dropped by up-submit

2 participants