fix(scheduler): handle preFlush cb queued inside postFlush cb
fix #3806
This commit is contained in:
parent
e8ddf86080
commit
b57e995edd
@ -230,6 +230,16 @@ describe('scheduler', () => {
|
||||
await nextTick()
|
||||
expect(calls).toEqual(['cb1', 'cb2', 'job1'])
|
||||
})
|
||||
|
||||
// #3806
|
||||
it('queue preFlushCb inside postFlushCb', async () => {
|
||||
const cb = jest.fn()
|
||||
queuePostFlushCb(() => {
|
||||
queuePreFlushCb(cb)
|
||||
})
|
||||
await nextTick()
|
||||
expect(cb).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('queuePostFlushCb', () => {
|
||||
|
@ -260,7 +260,11 @@ function flushJobs(seen?: CountMap) {
|
||||
currentFlushPromise = null
|
||||
// some postFlushCb queued jobs!
|
||||
// keep flushing until it drains.
|
||||
if (queue.length || pendingPostFlushCbs.length) {
|
||||
if (
|
||||
queue.length ||
|
||||
pendingPreFlushCbs.length ||
|
||||
pendingPostFlushCbs.length
|
||||
) {
|
||||
flushJobs(seen)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user