bigskysoftware / bigskysoftware/htmx

BUG: hx-target with special characters fails

Open
#2,601 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

If you have a hx-target that is an id that has special characters like the colon fails because they need to be escaped for `document.querySelectorAll`.

![image](https://github.com/bigskysoftware/htmx/assets/29479033/dc4738ee-f4be-4e6d-8644-673feabb920d)
![image](https://github.com/bigskysoftware/htmx/assets/29479033/f0dd5a40-d67b-44b1-b380-d6d611ce67c1)
![image](https://github.com/bigskysoftware/htmx/assets/29479033/98e47829-61ab-487d-98a0-ba852c540410)

Same happens on console and you can fix it by adding a `\\`.
![image](https://github.com/bigskysoftware/htmx/assets/29479033/a3ffdd23-1f72-4c7b-9f02-120fb8201acf)

HTML spec allows at least hyphens and colons and dots to be used.
https://www.w3.org/TR/html4/types.html#:~:text=ID%20and%20NAME%20tokens%20must,periods%20(".").

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests; first reproduce an hx-target containing a colon, hyphen, or dot and inspect the code that passes the target to document.querySelectorAll. Done means valid HTML IDs with these characters resolve correctly, including a regression check for the reported selector behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.