Skip to content

feat(core): support formaction=${action} on submitters (#1207) - #1210

Open
vivek7405 wants to merge 6 commits into
mainfrom
feat/formaction-submitter
Open

feat(core): support formaction=${action} on submitters (#1207)#1210
vivek7405 wants to merge 6 commits into
mainfrom
feat/formaction-submitter

Conversation

@vivek7405

Copy link
Copy Markdown
Collaborator

Closes #1207

Overview

This PR adds support for formaction=${action} on submitters (<button> and <input type="submit">) inside bound forms (<form action=${formAction}>).

Key Changes

  1. Core Runtime (form-action.js, render-server.js, render-client.js):

    • Recognized formaction=${action} on <button> and <input> submitters.
    • Refused unparseable options: submitter name attribute, input type="image", formmethod="get", formenctype="text/plain", or submitter outside a bound <form action=${...}>.
    • In SSR (renderTemplate & streamTemplate), deferred submitter validation to tag-end close (>) to inspect author-written attributes following formaction=${action}.
    • Emits <button name="__webjs_action" value="<hash>/<fn>"> directly into rendered HTML.
    • Updated client-side reconciliation (buildFormActionRecord, reconcileFormActions, reconcileSubmitterAction) for CSR.
  2. Server Action Dispatch (form-dispatch.js):

    • Extracted formData.getAll(FORM_ACTION_FIELD) and selected actions[actions.length - 1], matching standard WHATWG DOM order last-wins submitter precedence with JS OFF.
  3. Auditor (check.js):

    • Extended form-action-not-a-get-action to check submitters (<button> and <input>).
  4. Testing & Docs:

    • Added unit tests across core (form-action-binding.test.js, form-action-binding-client.test.js, form-action-attr-guard.test.js, form-action-attr-guard-client.test.js), server (form-dispatch.test.js), and Bun parity (test/bun/form-action-submitter-parity.test.mjs, test/bun/form-action-guard.mjs).
    • Updated documentation in AGENTS.md, .agents/skills/webjs/references/, and website/app/docs/{server-actions,progressive-enhancement,migrating-from-nextjs,troubleshooting}/page.ts.

@vivek7405 vivek7405 self-assigned this Aug 1, 2026
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.

Support formaction=${action} for per-button actions, and refuse unparseable submitter enctype

1 participant