Skip to content

Commit

Permalink
fix: only setupScroll when support pushState due to possible fallback…
Browse files Browse the repository at this point in the history
…: false (#1835)

* fix #1834

* judge supportsPushState before setupScroll

* expectScroll -> supportsScroll
  • Loading branch information
JounQin authored and yyx990803 committed Oct 24, 2017
1 parent 9eecbd9 commit fac60f6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/history/html5.js
Expand Up @@ -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()
}

Expand All @@ -29,7 +30,7 @@ export class HTML5History extends History {
}

this.transitionTo(location, route => {
if (expectScroll) {
if (supportsScroll) {
handleScroll(router, route, current, true)
}
})
Expand Down

0 comments on commit fac60f6

Please sign in to comment.