Repository navigation
tag-helpers: reject aliases of attributes that the Tag Helpers render - #118
Merged
Merged
Conversation
The conflict check looked only at the hx-* name, but HTMX also reads an alias: data-hx-* on HTMX 1.9.x and 2.x, and the configured prefix on HTMX 4.x. With both on one element, one value was silently lost. A generated hx-vals hid a hand-written data-hx-vals, and on HTMX 4.x a hand-written data-hx-vals hid a generated hx-vals:inherited or hx-vals:append. The check now covers the alias and follows HtmxV4Config.Prefix: with a custom prefix, data-hx-* stays an ordinary attribute, and an empty prefix means there is no alias.
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.
hx-val-*,hx-header-*, andhx-request-*already reject a hand-writtenhx-vals,hx-headers,hx-request, orhx-configon the same element (PR #115). That check looked only at thehx-*name, but HTMX also reads an alias of these attributes, so the same conflict went unnoticed and one value was silently lost:hx-valshid a hand-writtendata-hx-vals;data-hx-valshid a generatedhx-vals:inheritedorhx-vals:append.The check now covers the alias:
data-hx-HtmxV4Config.Prefix,data-hx-by defaultPrefix = ""With a custom prefix, HTMX no longer reads
data-hx-*, so those attributes stay ordinary and do not throw.The comparison works on spans and does not allocate.
HtmxUrlTagHelperis unchanged. Two request attributes on one element are a mistake with or withoutthe Toolkit, and the docs already say that it recognizes only the
hx-prefix.