Skip to content

fix #1675 #1677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/history/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -190,6 +192,10 @@ export class History {
hook && hook(route, prev)
})
}

shouldUpdateRoute (): boolean {
return true
}
}

function normalizeBase (base: ?string): string {
Expand Down
8 changes: 7 additions & 1 deletion src/history/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down