Skip to content

Fix scrollToHash to handle hashes starting with a number#481

Merged
ryansolid merged 2 commits intosolidjs:mainfrom
CirnoV:patch-1
Sep 25, 2024
Merged

Fix scrollToHash to handle hashes starting with a number#481
ryansolid merged 2 commits intosolidjs:mainfrom
CirnoV:patch-1

Conversation

@CirnoV
Copy link
Copy Markdown
Contributor

@CirnoV CirnoV commented Sep 24, 2024

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

@changeset-bot
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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