-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
hashchange event not working in 2.8 #1807
Comments
In 2.8 & 3.0 I'd recommend using a more implementation-agnostic way to detect route change, e.g. |
it can also be work like this instead of window.addEventListener('hashchange') |
@yyx990803 Sorry I don't get why the default behavior overrides a well known configuration. If I use What about introducing a dedicated //EDIT: checking it again it seems there is already the Does that mean you fixed it? |
@julianxhokaxhiu The API has never made any guarantee on whether a |
My target was not related to the Vue ecosystem, but other libraries that may interact with native DOM events. I get that the library was not giving guarantee, but in my honest opinion I think that when you keep such a feature for long time, you definitely do not want to change it under the hood. |
@julianxhokaxhiu for your use case, a very simple workaround: dispatch a |
Sure, the workaround may work and it's fine. What happens if you have already that event dispatched? This means that you have to check if the push-state is supported first right? So again, this means overhead on top of a well known behavior. Unless Vue Router gives a guarantee that the afterEach is called only when a push-state happens. |
function pushHash (path) {
if (supportsPushState) {
pushState(getUrl(path));
} else {
window.location.hash = path;
}
} all because above |
It also doesn't work in version 2.1.4 |
Version
2.8.0 & 3.0.0
Reproduction link
http://jsfiddle.net/9r6xhqbp/41/
Steps to reproduce
Switch between
/home
and/foo
What is expected?
hashchange
triggers and you'll see1
s printed in the console.What is actually happening?
Nothing is printed.
hashchange
works fine in 2.7.0: http://jsfiddle.net/9r6xhqbp/40/The text was updated successfully, but these errors were encountered: