Skip to content
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

replaceState needs third argument #2195

Closed
raxxarr opened this issue May 14, 2018 · 3 comments
Closed

replaceState needs third argument #2195

raxxarr opened this issue May 14, 2018 · 3 comments
Labels

Comments

@raxxarr
Copy link

raxxarr commented May 14, 2018

Version

3.0.1

Reproduction link

https://github.com/raxxarr/router-demo.git

Steps to reproduce

  • in latest Safari(OS X or iOS)
  • add base element: <base href="/app/">
  • set router mode: history
  1. open page 1 via url: localhost:8080/app/p1
  2. navigate to /app/p2 by clicking button
  3. click history back button on browser

What is expected?

jump back to /app/p1

What is actually happening?

jump to /app/


This issue is caused by using replaceState without giving a third argument when trying to fix a Firefox scroll issue (https://github.com/vuejs/vue-router/blob/dev/src/util/scroll.js#L9); This works fine on most browsers except for Safari.
According to whatwg spec,if the 3rd argument is not given,browser should set current url into history,but Safari set the base url.
Here is Webkit source code: https://trac.webkit.org/browser/webkit/branches/safari-605.2.8.1-branch/Source/WebCore/page/History.cpp#L157
Here is Blink source code: https://chromium.googlesource.com/chromium/blink/ /master/Source/core/frame/History.cpp#153
As is seen, what Safari do is not what we expect when we omit the 3rd argument.

Although this is not really a vue-router bug, we can add a third argument(current path) to avoid something weird happen.

ps: this bug is confirmed by Webkit https://bugs.webkit.org/show_bug.cgi?id=182678

@LinusBorg
Copy link
Member

note: the minimal reproduction cannot reproduce the issue because I don't know how to use url to change route in JSFiddle

You can also provide a repository or use codesandbox.io, for example.

@raxxarr
Copy link
Author

raxxarr commented May 14, 2018

@LinusBorg I've add a demo repository to reproduce this issue.

@posva
Copy link
Member

posva commented Jul 12, 2018

Thanks for reporting this. I created a PR, need to check tests and on IE to add a conditional call or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants