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

router.go() does not work in Safari #2554

Closed
Johnsoct opened this Issue Dec 26, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@Johnsoct
Copy link

Johnsoct commented Dec 26, 2018

Version

3.0.1

Reproduction link

https://codesandbox.io/s/zljj518k94

Steps to reproduce

Setup this.$router.go() (essentially, refresh the page without any data) and try triggering it in Safari.

In code sandbox, using Safari, if you click the button (calls this.$router.go()) an error is thrown. If you do the same in Chrome, for example, nothing happens (I assume it's due to being inside their sandbox) but remains error-free.

What is expected?

Page refresh without data

What is actually happening?

Nothing at all


I'm not experienced with picking source code apart, but I did a bit of digging to see if any recent merges may have caused because I believe the issue to be new as of within one week's time.

@posva

This comment has been minimized.

Copy link
Member

posva commented Dec 26, 2018

Please check the documentation at https://router.vuejs.org, you should pass the router instance to the mani Vue instance. You are passing The Router constructor

@posva posva closed this Dec 26, 2018

@Johnsoct

This comment has been minimized.

Copy link

Johnsoct commented Dec 26, 2018

@posva I made these updates and it's still not functioning. this.$router.go() has zero effect in Safari.

(the application I'm working on is setup correctly. I just rushed the reproduction sandbox)

Here is my exact setup for vue-router:
main.js

import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store/index';

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app');

router.js

// Dependency Imports
import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export default new Router({...})

Again, using this.$router.go() anywhere works in Chrome and Firefox, but has zero effect in Safari. Here is a video of the behavior: http://recordit.co/lpKpKQB3XP

@posva

This comment has been minimized.

Copy link
Member

posva commented Dec 26, 2018

Please, check the docs for the go function, you are passing no parameters or anything... Make sure you are not mistakenly using go instead of push.


Please, next time consider using the forum, the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug 🙂

@Johnsoct

This comment has been minimized.

Copy link

Johnsoct commented Dec 26, 2018

Alright, I've already read the documentation quite a few times and I've already tried Discord and used StackOverflow to get to this example. I appreciate your time, but if you could take a second instead of immediately blowing this off, that would be great.

The vue-router docs mention it imitates the browser history API, which for window.history.go() if you do not pass a parameter reloads the current page: https://developer.mozilla.org/en-US/docs/Web/API/History.

This is working as expected in Chrome and Firefox, but not in Safari. However, if I put any parameter other than 0 or empty (numbers only), it works in Safari. This is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment