Skip to content

Commit 32c6b38

Browse files
Fix: ready/doneEach order with async afterEach (#1770)
1 parent 63b2535 commit 32c6b38

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/core/render/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,15 @@ export function Render(Base) {
321321
);
322322
}
323323

324-
this.callHook('afterEach', html, hookData =>
325-
renderMain.call(this, hookData)
326-
);
324+
this.callHook('afterEach', html, hookData => {
325+
renderMain.call(this, hookData);
326+
next();
327+
});
327328
};
328329

329330
if (this.isHTML) {
330331
html = this.result = text;
331332
callback();
332-
next();
333333
} else {
334334
prerenderEmbed(
335335
{
@@ -339,7 +339,6 @@ export function Render(Base) {
339339
tokens => {
340340
html = this.compiler.compile(tokens);
341341
callback();
342-
next();
343342
}
344343
);
345344
}

test/e2e/plugins.test.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test.describe('Plugins', () => {
99
'mounted',
1010
'beforeEach-async',
1111
'beforeEach',
12-
// 'afterEach-async',
12+
'afterEach-async',
1313
'afterEach',
1414
'doneEach',
1515
'ready',
@@ -41,13 +41,12 @@ test.describe('Plugins', () => {
4141
return markdown;
4242
});
4343

44-
// FIXME: https://github.com/docsifyjs/docsify/issues/449
45-
// hook.afterEach(function (html, next) {
46-
// setTimeout(function () {
47-
// console.log('afterEach-async');
48-
// next(html);
49-
// }, 100);
50-
// });
44+
hook.afterEach(function (html, next) {
45+
setTimeout(function () {
46+
console.log('afterEach-async');
47+
next(html);
48+
}, 100);
49+
});
5150

5251
hook.afterEach(function (html) {
5352
console.log('afterEach');

0 commit comments

Comments
 (0)