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 scrollToHash to handle hashes starting with a number #481

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

CirnoV
Copy link
Contributor

@CirnoV CirnoV commented Sep 24, 2024

When hash starts with a number, document.querySelector throws an error, causing scrollToHash to fail.

Copy link

changeset-bot bot commented Sep 24, 2024

🦋 Changeset detected

Latest commit: c61231d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ryansolid
Copy link
Member

Do you see any reason why we wouldn't always use get document by id? I admit I wasn't responsible for the hash router implementation so the fact that there is all this query selector stuff just for this case sort of surprises me. I will do some forensics here but the native DOM behavior seems to be restricted to ids so I don't see benefit in applying a general selector and trying to restrict it to fit.

@ryansolid ryansolid merged commit cf0ebbf into solidjs:main Sep 25, 2024
@CirnoV CirnoV deleted the patch-1 branch September 26, 2024 05:03
@CirnoV
Copy link
Contributor Author

CirnoV commented Sep 26, 2024

I prefer to use document.getElementById, but since there might be cases in the existing project where a selector is used (even though it's not documented), I was a bit hesitant to change the code.

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.

2 participants