Skip to content

Fix popstate handler sending wrong parameters to scrollBehavior #1479

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

Merged
merged 1 commit into from
May 30, 2017

Conversation

mutoo
Copy link
Contributor

@mutoo mutoo commented May 30, 2017

I found that the scrollBehavior callback received the same route object as to and from parameters when users click the browser's back/forward button.

Then I followed the call stacks and found that there was a one line bug at history/html5.js

    window.addEventListener('popstate', e => {
      this.transitionTo(getLocation(this.base), route => {
        if (expectScroll) {
          handleScroll(router, route, this.current, true)
        }
      })
    })

Actually the this.current is changed before the callback be called.

Since it's a bit hard to provide a history-mode demo in codepen/jsfiddle, and the bug is so obvious.
There is any demo be provided. Sorry about that.

version: vue-router 2.5.3

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @yyx990803

@yyx990803 yyx990803 merged commit f9570db into vuejs:dev May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants