Skip to content

Commit cf0ebbf

Browse files
authored
Merge pull request #481 from CirnoV/patch-1
Fix scrollToHash to handle hashes starting with a number
2 parents 626c224 + c61231d commit cf0ebbf

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

.changeset/hungry-trees-explode.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/router": patch
3+
---
4+
5+
Fix scrollToHash to handle hashes starting with a number

src/routers/createRouter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function bindEvent(target: EventTarget, type: string, handler: EventListe
6565
}
6666

6767
export function scrollToHash(hash: string, fallbackTop?: boolean) {
68-
const el = querySelector(`#${hash}`);
68+
const el = querySelector(`#${hash}`) ?? document.getElementById(hash);
6969
if (el) {
7070
el.scrollIntoView();
7171
} else if (fallbackTop) {

0 commit comments

Comments
 (0)