-
-
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
add the replace attribute in location for hooking in beforeEach #1906
base: dev
Are you sure you want to change the base?
Conversation
e... |
Hey, sorry for the delay. What are you trying to achieve? The issue you linked is closed. Why are you always setting replace to true if location is an object? |
If somebody reset the path in beforeEach, the new path will be open as push type, actually, it will be puzzled if the original router path is replace type. In this PR, the replace setting of location in the $router.replace() will be set as true, so the developer can find the route's type in the beforeEach hooking. |
Aaah, is the issue you're referring to #1620? |
yes. And the vue-router has supported the replace type checking in the route guards next() in this commit: d53ec3c This pr is an expand of that commit. |
ok, could you add some tests to make sure the property is added in different scenarios but not others? (push/replace/calling it with next) |
I have added an example for this commit. |
Is there any progress? I waiting for this PR to be merged for a long time. |
I am waiting for this PR to be merged too.. |
This will probably come along with other changes that would allow knowing what kind of navigation happened (back, forward, push, replace) |
@posva is there any plan to add these features? we are waiting for this feature too too too too too long. almost a year. |
Around one year after the last post, I would like to ask if this branch will be merged some day. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! There is no need to add a new e2e spec, we can add a test to the existing basic
e2e test instead
if (typeof location === 'object' && !location.replace) { | ||
(location: Object).replace = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since location is an object at this point, we can directly set replace
to true
if (typeof location === 'object' && !location.replace) { | |
(location: Object).replace = true | |
} | |
(location: Object).replace = true |
@@ -52,10 +52,13 @@ export function normalizeLocation ( | |||
hash = `#${hash}` | |||
} | |||
|
|||
const replace = next.replace || false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to create a new variable. It can also be written as !!next.replace
@@ -23,6 +23,7 @@ export function createRoute ( | |||
meta: (record && record.meta) || {}, | |||
path: location.path || '/', | |||
hash: location.hash || '', | |||
replace: location.replace || false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace: location.replace || false, | |
replace: !!location.replace, |
issue vuejs#1620 pull request vuejs#1906
issue vuejs#1620 pull request vuejs#1906
issue vuejs#1620 pull request vuejs#1906
Closes #1620