Skip to content

Commit

Permalink
Fix: ready/doneEach order with async afterEach (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhildenbiddle authored Mar 16, 2022
1 parent 63b2535 commit 32c6b38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/core/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -339,7 +339,6 @@ export function Render(Base) {
tokens => {
html = this.compiler.compile(tokens);
callback();
next();
}
);
}
Expand Down
15 changes: 7 additions & 8 deletions test/e2e/plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test.describe('Plugins', () => {
'mounted',
'beforeEach-async',
'beforeEach',
// 'afterEach-async',
'afterEach-async',
'afterEach',
'doneEach',
'ready',
Expand Down Expand Up @@ -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');
Expand Down

1 comment on commit 32c6b38

@vercel
Copy link

@vercel vercel bot commented on 32c6b38 Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.