From fac60f63401be86c5a76124782de28f600e7694b Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 24 Oct 2017 19:59:45 +0800 Subject: [PATCH] fix: only setupScroll when support pushState due to possible fallback: false (#1835) * fix #1834 * judge supportsPushState before setupScroll * expectScroll -> supportsScroll --- src/history/html5.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/history/html5.js b/src/history/html5.js index 17e1c5cbe..95c47344c 100644 --- a/src/history/html5.js +++ b/src/history/html5.js @@ -5,15 +5,16 @@ import { History } from './base' import { cleanPath } from '../util/path' import { START } from '../util/route' import { setupScroll, handleScroll } from '../util/scroll' -import { pushState, replaceState } from '../util/push-state' +import { pushState, replaceState, supportsPushState } from '../util/push-state' export class HTML5History extends History { constructor (router: Router, base: ?string) { super(router, base) const expectScroll = router.options.scrollBehavior + const supportsScroll = supportsPushState && expectScroll - if (expectScroll) { + if (supportsScroll) { setupScroll() } @@ -29,7 +30,7 @@ export class HTML5History extends History { } this.transitionTo(location, route => { - if (expectScroll) { + if (supportsScroll) { handleScroll(router, route, current, true) } })