Repository navigation
Fix hx-on handlers on forms with inputs named attributes - #4141
Open
sergioperezcheco wants to merge 1 commit into
Open
sergioperezcheco wants to merge 1 commit into
sergioperezcheco wants to merge 1 commit into
Conversation
Assisted-by: Hermes Agent (Nous Research) Signed-off-by: sergioperezcheco <checo520@outlook.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Forms can expose a control named
attributesthrough their named-property getter instead of returning the form's attribute map. This causeshx-on:*discovery and handler initialization to miss the form, and prevents changed AJAX attributes from being reinitialized. UsegetAttributeNames()andgetAttribute()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 testcommand 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
devnpm run testexecuted; equivalent upstream Chromium harness and both prerequisite checks passed as described above