Skip to content

Commit 453ec6b

Browse files
authored
prevents access to the history state if not set (#12436)
1 parent e64ec5f commit 453ec6b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/dirty-teachers-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes a potential null access in the clientside router

packages/astro/src/transitions/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ if (inBrowser) {
636636
'scroll',
637637
() => {
638638
if (intervalId !== undefined) return;
639-
(lastIndex = history.state.index), (lastY = scrollY), (lastX = scrollX);
639+
(lastIndex = history.state?.index), (lastY = scrollY), (lastX = scrollX);
640640
intervalId = window.setInterval(scrollInterval, 50);
641641
},
642642
{ passive: true },

0 commit comments

Comments
 (0)