fix(runtime-core): avoid double firing when mounting inside a watcher callback
fix #6614
This commit is contained in:
parent
6493da5bfa
commit
6aaf8efeff
@ -534,4 +534,16 @@ describe('scheduler', () => {
|
|||||||
// should not be called
|
// should not be called
|
||||||
expect(spy).toHaveBeenCalledTimes(0)
|
expect(spy).toHaveBeenCalledTimes(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('flushPreFlushCbs inside a pre job', async () => {
|
||||||
|
const spy = jest.fn()
|
||||||
|
const job = () => {
|
||||||
|
spy()
|
||||||
|
flushPreFlushCbs()
|
||||||
|
}
|
||||||
|
job.pre = true
|
||||||
|
queueJob(job)
|
||||||
|
await nextTick()
|
||||||
|
expect(spy).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -133,7 +133,11 @@ export function queuePostFlushCb(cb: SchedulerJobs) {
|
|||||||
queueFlush()
|
queueFlush()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function flushPreFlushCbs(seen?: CountMap, i = flushIndex) {
|
export function flushPreFlushCbs(
|
||||||
|
seen?: CountMap,
|
||||||
|
// if currently flushing, skip the current job itself
|
||||||
|
i = isFlushing ? flushIndex + 1 : 0
|
||||||
|
) {
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
seen = seen || new Map()
|
seen = seen || new Map()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user