Skip to content

Fix hx-on handlers on forms with inputs named attributes - #4141

Open
sergioperezcheco wants to merge 1 commit into
bigskysoftware:devfrom
sergioperezcheco:fix/form-named-attributes-handlers
Open

sergioperezcheco wants to merge 1 commit into
bigskysoftware:devfrom
sergioperezcheco:fix/form-named-attributes-handlers

Conversation

@sergioperezcheco

Copy link
Copy Markdown

Description

Forms can expose a control named attributes through their named-property getter instead of returning the form's attribute map. This causes hx-on:* discovery and handler initialization to miss the form, and prevents changed AJAX attributes from being reinitialized. Use getAttributeNames() and getAttribute() in the three affected paths, retaining attribute order and the existing empty-value hash behavior.

Fixes #2202. For example, <form hx-post="/save" hx-on::config-request="event.detail.parameters.extra = 'added'"><input name="attributes"><button>Submit</button></form> now invokes the handler without changing the submitted field name.

Testing

Added six regression cases covering colon/dash/data spellings, handler replacement without duplication, nested duplicate-name controls, and changed request URLs. The new tests fail against the unchanged source and pass with the fix. Lint and JavaScript type checks passed; the complete upstream Chromium harness passed with a launcher override selecting an existing Chromium executable (874 passed, 3 skipped). The literal npm test command was not run, since it installs a browser; the override preserves the upstream HTML harness, file selection, reporters and coverage. Official distribution generation and real HTTP/browser checks of both source and built output passed. Firefox, WebKit and other-platform matrices were not run locally.

A local nine-sample initialization check over 1,000 ordinary forms measured medians of 11.4 ms before and 12.4 ms after; this is a small absolute increase, not a claim of zero overhead. This patch and its verification were prepared by an automated AI agent; no human review is claimed.

Checklist

  • Contribution guidelines read
  • Source changes target dev
  • Existing behavior bugfix, with regression tests and documentation
  • Literal npm run test executed; equivalent upstream Chromium harness and both prerequisite checks passed as described above

Assisted-by: Hermes Agent (Nous Research)
Signed-off-by: sergioperezcheco <checo520@outlook.com>
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