Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Use getElementById instead of querySelector to work with all valid characters #1902

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

jyrimatti
Copy link
Contributor

Currently clicking the link on this:

<html>
    <head>
        <script src="https://unpkg.com/[email protected]/dist/htmx.js" ></script>
    </head>
    <body>
        <a href="" hx-get="other.html#foo()bar">Click me</a>
    </body>
</html>

results in

DOMException: Failed to execute 'querySelector' on 'Document': '#foo()bar' is not a valid selector.

on line 492.

Since responseInfo.pathInfo.anchor is assumed to be an ID here, use getElementById instead of querySelector to allow all characters.

I can't see any problems with this change, but please let me know if I'm missing something.

…lementById instead of querySelector, which doesn't accept all valid characters (for example parentheses)
@Telroshan Telroshan added the bug Something isn't working label Oct 20, 2023
@alexpetros
Copy link
Collaborator

Oh yeah, that looks right.

@alexpetros alexpetros added the ready for review Issues that are ready to be considered for merging label Oct 20, 2023
@1cg 1cg merged commit 1040ace into bigskysoftware:dev Oct 26, 2023
1 check passed
@1cg
Copy link
Contributor

1cg commented Oct 26, 2023

thank you!

@jyrimatti jyrimatti deleted the anchor-accept-all-characters branch January 21, 2024 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for review Issues that are ready to be considered for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants