From 87c602eedf7c4cecb291933364349357385b5fc7 Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Sun, 13 Mar 2022 16:01:24 -0500 Subject: [PATCH 1/2] Fix ready/doneEach order with async afterEach fix #449 --- src/core/render/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/render/index.js b/src/core/render/index.js index e4e63f76d..4f4a6da3e 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -321,15 +321,15 @@ export function Render(Base) { ); } - this.callHook('afterEach', html, hookData => - renderMain.call(this, hookData) - ); + this.callHook('afterEach', html, hookData => { + renderMain.call(this, hookData); + next(); + }); }; if (this.isHTML) { html = this.result = text; callback(); - next(); } else { prerenderEmbed( { @@ -339,7 +339,6 @@ export function Render(Base) { tokens => { html = this.compiler.compile(tokens); callback(); - next(); } ); } From 0caa3799bcacc734d31673dbca9fa296541b3d59 Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Tue, 15 Mar 2022 00:34:55 -0500 Subject: [PATCH 2/2] Update tests w/ fixed async afterEach behavior --- test/e2e/plugins.test.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/e2e/plugins.test.js b/test/e2e/plugins.test.js index 92f00ca56..2f3ff4b7e 100644 --- a/test/e2e/plugins.test.js +++ b/test/e2e/plugins.test.js @@ -9,7 +9,7 @@ test.describe('Plugins', () => { 'mounted', 'beforeEach-async', 'beforeEach', - // 'afterEach-async', + 'afterEach-async', 'afterEach', 'doneEach', 'ready', @@ -41,13 +41,12 @@ test.describe('Plugins', () => { return markdown; }); - // FIXME: https://github.com/docsifyjs/docsify/issues/449 - // hook.afterEach(function (html, next) { - // setTimeout(function () { - // console.log('afterEach-async'); - // next(html); - // }, 100); - // }); + hook.afterEach(function (html, next) { + setTimeout(function () { + console.log('afterEach-async'); + next(html); + }, 100); + }); hook.afterEach(function (html) { console.log('afterEach');