fix(router): replace next() deprecated in Vue Router v5#22643
fix(router): replace next() deprecated in Vue Router v5#22643J-Sek merged 2 commits intovuetifyjs:masterfrom
next() deprecated in Vue Router v5#22643Conversation
3ceb0d1 to
524e981
Compare
|
Hey guys, patches below works fine for me : diff --git a/lib/composables/router.js b/lib/composables/router.js
index fd42accc1674e85a542ca960e38676fd6878e2e5..3790ca4f5b3b9ec817f4907c138c2c1382703ec6 100644
--- a/lib/composables/router.js
+++ b/lib/composables/router.js
@@ -75,13 +75,25 @@ export function useBackButton(router, cb) {
if (IN_BROWSER && router?.beforeEach) {
nextTick(() => {
window.addEventListener('popstate', onPopstate);
- removeBefore = router.beforeEach((to, from, next) => {
+ removeBefore = router.beforeEach((to, from) => {
+ if (to === from) return;
+ const runCallback = () => {
+ let result;
+ const next = (val) => { result = val; };
+ if (popped) {
+ cb(next);
+ return result;
+ }
+ return undefined;
+ };
if (!inTransition) {
- setTimeout(() => popped ? cb(next) : next());
- } else {
- popped ? cb(next) : next();
+ inTransition = true;
+ return new Promise((resolve) => {
+ setTimeout(() => resolve(runCallback()));
+ });
}
inTransition = true;
+ return runCallback();
});
removeAfter = router?.afterEach(() => {
inTransition = false; |
|
@wusonw what do you think about my proposed change in this PR? |
524e981 to
0afdd99
Compare
|
When will this warning be fixed/removed? |
rude 😛 I am sick now and do it for free anyway since OC funds dried up. Can you download the repo, checkout this branch, build, point your app's package.json to the Tip: add |
J-Sek
left a comment
There was a problem hiding this comment.
These new tests hardly make any sense to me. Either I need some explanation or we should replace them with 2-3 cases in VDialog.spec.browser.tsx that are somewhat aligned with manual tests we would perform.
|
It was to unit-test the |
|
BTW, I think the issue in The current PR removes the deprecation warning in the console when using the I know, they are used in |
0afdd99 to
c921641
Compare
|
Hi, thanks for taking time to resolve the deprecation warnings. I would not mind unit-tests, but those were some kind of accidental nonsense that would only hurt us in the long run - by giving false confidence or failing for non-obvious reason. The more practical approach will be to have test for VDialog that are easy to grasp and repeat manually. You have proven the If you can tackle any other outstanding issue with |
next() callbacknext() deprecated in Vue Router v5
Co-authored-by: J-Sek <J-Sek@users.noreply.github.com> resolves #22632
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Warning gone after updating to the newly released v3.12.3 |
Description
resolves #22632
vue-router v5 added a deprecation notice in the usage of a
NavigationGuardNextfunction (https://router.vuejs.org/api/interfaces/NavigationGuardNext.html), the "new way" of using it is returning aNavigationGuardReturndirectly.NOTE: consider upgrading to vue-router v5.x in the repo before accepting/merging this
Markup:
Upgrade to vue-router 5.x to get the console warning: