summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Martin Trapp <94928215+martrapp@users.noreply.github.com> 2024-03-15 19:04:41 +0100
committerGravatar GitHub <noreply@github.com> 2024-03-15 19:04:41 +0100
commit1900a8f9bc337f3a882178d1770e10ab67fab0ce (patch)
tree24ed487a75b4bb92c45d9640e3b67bbaa6282735
parent8a80dbfddeb57d4890388aaa31e1033fac864fe8 (diff)
downloadastro-1900a8f9bc337f3a882178d1770e10ab67fab0ce.tar.gz
astro-1900a8f9bc337f3a882178d1770e10ab67fab0ce.tar.zst
astro-1900a8f9bc337f3a882178d1770e10ab67fab0ce.zip
Fixes an TypeError when using without (#10456)
-rw-r--r--.changeset/thirty-dancers-wink.md5
-rw-r--r--packages/astro/src/transitions/router.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/thirty-dancers-wink.md b/.changeset/thirty-dancers-wink.md
new file mode 100644
index 000000000..dfe386f44
--- /dev/null
+++ b/.changeset/thirty-dancers-wink.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Fixes an error when using `astro:transtions/client` without `<ViewTransitions/>`
diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts
index 69f4e717c..db5a5ea73 100644
--- a/packages/astro/src/transitions/router.ts
+++ b/packages/astro/src/transitions/router.ts
@@ -622,7 +622,7 @@ const onScrollEnd = () => {
// "scrollend" events. To avoid redundant work and expensive calls to
// `replaceState()`, we simply check that the values are different before
// updating.
- if (scrollX !== history.state.scrollX || scrollY !== history.state.scrollY) {
+ if (history.state && (scrollX !== history.state.scrollX || scrollY !== history.state.scrollY)) {
updateScrollPosition({ scrollX, scrollY });
}
};