mirror of https://github.com/vuejs/core.git
parent
324e817ef8
commit
d9162dfc2e
|
@ -610,4 +610,25 @@ describe('scheduler', () => {
|
||||||
expect(await p).toBe(1)
|
expect(await p).toBe(1)
|
||||||
expect(fn).toHaveBeenCalledTimes(1)
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #10003
|
||||||
|
test('nested flushPostFlushCbs', async () => {
|
||||||
|
const calls: string[] = []
|
||||||
|
const cb1 = () => calls.push('cb1')
|
||||||
|
// cb1 has no id
|
||||||
|
const cb2 = () => calls.push('cb2')
|
||||||
|
cb2.id = -1
|
||||||
|
const queueAndFlush = (hook: Function) => {
|
||||||
|
queuePostFlushCb(hook)
|
||||||
|
flushPostFlushCbs()
|
||||||
|
}
|
||||||
|
|
||||||
|
queueAndFlush(() => {
|
||||||
|
queuePostFlushCb([cb1, cb2])
|
||||||
|
flushPostFlushCbs()
|
||||||
|
})
|
||||||
|
|
||||||
|
await nextTick()
|
||||||
|
expect(calls).toEqual(['cb2', 'cb1'])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -164,7 +164,9 @@ export function flushPreFlushCbs(
|
||||||
|
|
||||||
export function flushPostFlushCbs(seen?: CountMap) {
|
export function flushPostFlushCbs(seen?: CountMap) {
|
||||||
if (pendingPostFlushCbs.length) {
|
if (pendingPostFlushCbs.length) {
|
||||||
const deduped = [...new Set(pendingPostFlushCbs)]
|
const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
||||||
|
(a, b) => getId(a) - getId(b),
|
||||||
|
)
|
||||||
pendingPostFlushCbs.length = 0
|
pendingPostFlushCbs.length = 0
|
||||||
|
|
||||||
// #1947 already has active queue, nested flushPostFlushCbs call
|
// #1947 already has active queue, nested flushPostFlushCbs call
|
||||||
|
@ -178,8 +180,6 @@ export function flushPostFlushCbs(seen?: CountMap) {
|
||||||
seen = seen || new Map()
|
seen = seen || new Map()
|
||||||
}
|
}
|
||||||
|
|
||||||
activePostFlushCbs.sort((a, b) => getId(a) - getId(b))
|
|
||||||
|
|
||||||
for (
|
for (
|
||||||
postFlushIndex = 0;
|
postFlushIndex = 0;
|
||||||
postFlushIndex < activePostFlushCbs.length;
|
postFlushIndex < activePostFlushCbs.length;
|
||||||
|
|
Loading…
Reference in New Issue