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

Should history.state object be extended rather than overridden? #3006

Comments

@ksurakka
Copy link

ksurakka commented Oct 22, 2019

What problem does this feature solve?

It makes it possible for other libraries to store and use information from history.state objects as they would not been overridden by vue-router.

I encountered this when I was trying to build a bookmarking feature. I was able to use keys provided by vue-router for this, but I was just thinking that overriding may cause hard-to-find problems in some environments and also because this overriding could be easy to replace by extending.

I mean these two lines in the codebase:

history.replaceState({ key: getStateKey() }, '', url)

history.pushState({ key: setStateKey(genStateKey()) }, '', url)

Using e.g.:
history.replaceState( {...history.state, ... { key: getStateKey() }}, '', url)

could cause less harm. Of course the key attribute would be still overridden.

What does the proposed API look like?

There are no API changes

@posva posva closed this as completed in c0d3376 Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment