]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
fix(scroll): only apply on browser
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 15 Apr 2020 14:45:36 +0000 (16:45 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 15 Apr 2020 14:45:36 +0000 (16:45 +0200)
src/utils/scroll.ts

index 2a4da68602ff03e1447957a1fa6c73493df62012..7e50c6b94c14b40def42708b7d0b0d7ca6a8f058 100644 (file)
@@ -1,5 +1,7 @@
 // import { RouteLocationNormalized } from '../types'
 
+import { isBrowser } from './env'
+
 export type ScrollToPosition = {
   x: number
   y: number
@@ -73,9 +75,8 @@ export function scrollToPosition(position: ScrollPosition): void {
 export const scrollPositions = new Map<string, ScrollToPosition>()
 
 export function getScrollKey(path: string, distance: number): string {
-  const position: number = history.state
-    ? history.state.position - distance
-    : -1
+  const position: number =
+    isBrowser && history.state ? history.state.position - distance : -1
   return position + path
 }