diff --git a/src/history/base.js b/src/history/base.js index 0c90dafa7..5c32ba186 100644 --- a/src/history/base.js +++ b/src/history/base.js @@ -64,7 +64,9 @@ export class History { transitionTo (location: RawLocation, onComplete?: Function, onAbort?: Function) { const route = this.router.match(location, this.current) this.confirmTransition(route, () => { - this.updateRoute(route) + if (this.shouldUpdateRoute()) { + this.updateRoute(route) + } onComplete && onComplete(route) this.ensureURL() @@ -190,6 +192,10 @@ export class History { hook && hook(route, prev) }) } + + shouldUpdateRoute (): boolean { + return true + } } function normalizeBase (base: ?string): string { diff --git a/src/history/html5.js b/src/history/html5.js index 37163703b..7b5f4ab27 100644 --- a/src/history/html5.js +++ b/src/history/html5.js @@ -4,7 +4,7 @@ import type Router from '../index' import { History } from './base' import { cleanPath } from '../util/path' 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) { @@ -58,6 +58,12 @@ export class HTML5History extends History { getCurrentLocation (): string { return getLocation(this.base) } + + shouldUpdateRoute (): boolean { + // when is ready and don't support pushState + // route shouldn't render, it suppose to be regular page jump + return !this.ready || supportsPushState + } } export function getLocation (base: string): string {