From: Eduardo San Martin Morote Date: Wed, 15 Apr 2020 14:45:36 +0000 (+0200) Subject: fix(scroll): only apply on browser X-Git-Tag: v4.0.0-alpha.6~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf53192b77d619b1e43c8decda76d4083d9c17ea;p=thirdparty%2Fvuejs%2Frouter.git fix(scroll): only apply on browser --- diff --git a/src/utils/scroll.ts b/src/utils/scroll.ts index 2a4da686..7e50c6b9 100644 --- a/src/utils/scroll.ts +++ b/src/utils/scroll.ts @@ -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() 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 }