Skip to content

Commit

Permalink
Merge pull request #481 from CirnoV/patch-1
Browse files Browse the repository at this point in the history
Fix scrollToHash to handle hashes starting with a number
  • Loading branch information
ryansolid authored Sep 25, 2024
2 parents 626c224 + c61231d commit cf0ebbf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/hungry-trees-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/router": patch
---

Fix scrollToHash to handle hashes starting with a number
2 changes: 1 addition & 1 deletion src/routers/createRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function bindEvent(target: EventTarget, type: string, handler: EventListe
}

export function scrollToHash(hash: string, fallbackTop?: boolean) {
const el = querySelector(`#${hash}`);
const el = querySelector(`#${hash}`) ?? document.getElementById(hash);
if (el) {
el.scrollIntoView();
} else if (fallbackTop) {
Expand Down

0 comments on commit cf0ebbf

Please sign in to comment.