Fix: ready/doneEach order with async afterEach (#1770)

This commit is contained in:
John Hildenbiddle 2022-03-15 19:15:12 -05:00 committed by GitHub
parent 63b2535a45
commit 32c6b3804e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View File

@ -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();
}
);
}

View File

@ -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');