From b8519d04495ec31ec06f46bb739281118bbc2f1e Mon Sep 17 00:00:00 2001 From: Ricardo Gobbo de Souza Date: Fri, 25 Oct 2019 13:22:12 -0300 Subject: [PATCH 1/2] fix: afterNavigation --- src/shared/nav-guards.js | 10 ++++++---- test/unit/components.test.js | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/shared/nav-guards.js b/src/shared/nav-guards.js index c63d9251..805d122f 100644 --- a/src/shared/nav-guards.js +++ b/src/shared/nav-guards.js @@ -19,10 +19,12 @@ export function addNavGuards (rootVm) { }) router.afterEach(() => { - const { metaInfo } = resume(rootVm) + rootVm.$nextTick(function () { + const { metaInfo } = resume(rootVm) - if (metaInfo && isFunction(metaInfo.afterNavigation)) { - metaInfo.afterNavigation(metaInfo) - } + if (metaInfo && isFunction(metaInfo.afterNavigation)) { + metaInfo.afterNavigation(metaInfo) + } + }) }) } diff --git a/test/unit/components.test.js b/test/unit/components.test.js index 2b9e3d0c..5d01b20c 100644 --- a/test/unit/components.test.js +++ b/test/unit/components.test.js @@ -271,6 +271,8 @@ describe('components', () => { expect(wrapper.vm.$root._vueMeta.pausing).toBe(true) guards.after() + expect(afterNavigation).not.toHaveBeenCalled() + await vmTick(wrapper.vm) expect(afterNavigation).toHaveBeenCalled() }) @@ -306,6 +308,8 @@ describe('components', () => { expect(wrapper.vm.$root._vueMeta.pausing).toBe(true) guards.after() + expect(afterNavigation).not.toHaveBeenCalled() + await vmTick(wrapper.vm) expect(afterNavigation).toHaveBeenCalled() }) From b39ef9b05e602eaa298e85e175b3ddcb1ff1515f Mon Sep 17 00:00:00 2001 From: Ricardo Gobbo de Souza Date: Sun, 27 Oct 2019 16:52:33 -0300 Subject: [PATCH 2/2] style: use arrow function --- src/shared/nav-guards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/nav-guards.js b/src/shared/nav-guards.js index 805d122f..135609ac 100644 --- a/src/shared/nav-guards.js +++ b/src/shared/nav-guards.js @@ -19,7 +19,7 @@ export function addNavGuards (rootVm) { }) router.afterEach(() => { - rootVm.$nextTick(function () { + rootVm.$nextTick(() => { const { metaInfo } = resume(rootVm) if (metaInfo && isFunction(metaInfo.afterNavigation)) {