aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Martin Trapp <94928215+martrapp@users.noreply.github.com> 2024-11-15 09:09:05 +0100
committerGravatar GitHub <noreply@github.com> 2024-11-15 16:09:05 +0800
commit453ec6b12f8c021e0bd0fd0ea9f71c8fc280f4b1 (patch)
tree122b4329053357f8e2be8fffcd6fc68b4eb5880d
parente64ec5f9df7115d3d969dfe84f11ef4aa0af5f33 (diff)
downloadastro-453ec6b12f8c021e0bd0fd0ea9f71c8fc280f4b1.tar.gz
astro-453ec6b12f8c021e0bd0fd0ea9f71c8fc280f4b1.tar.zst
astro-453ec6b12f8c021e0bd0fd0ea9f71c8fc280f4b1.zip
prevents access to the history state if not set (#12436)
-rw-r--r--.changeset/dirty-teachers-know.md5
-rw-r--r--packages/astro/src/transitions/router.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/dirty-teachers-know.md b/.changeset/dirty-teachers-know.md
new file mode 100644
index 000000000..951117fff
--- /dev/null
+++ b/.changeset/dirty-teachers-know.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fixes a potential null access in the clientside router
diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts
index 2be12895e..cb5476a7a 100644
--- a/packages/astro/src/transitions/router.ts
+++ b/packages/astro/src/transitions/router.ts
@@ -636,7 +636,7 @@ if (inBrowser) {
'scroll',
() => {
if (intervalId !== undefined) return;
- (lastIndex = history.state.index), (lastY = scrollY), (lastX = scrollX);
+ (lastIndex = history.state?.index), (lastY = scrollY), (lastX = scrollX);
intervalId = window.setInterval(scrollInterval, 50);
},
{ passive: true },