fix(scheduler): sort jobs before flushing
This fixes the case where a child component is added to the queue before its parent, but should be invalidated by its parent's update. Same logic was present in Vue 2. Properly fixes #910 ref: https://github.com/vuejs/vue-next/issues/910#issuecomment-613097539
This commit is contained in:
@@ -262,4 +262,20 @@ describe('scheduler', () => {
|
||||
// job2 should be called only once
|
||||
expect(calls).toEqual(['job1', 'job2', 'job3', 'job4'])
|
||||
})
|
||||
|
||||
test('sort job based on id', async () => {
|
||||
const calls: string[] = []
|
||||
const job1 = () => calls.push('job1')
|
||||
// job1 has no id
|
||||
const job2 = () => calls.push('job2')
|
||||
job2.id = 2
|
||||
const job3 = () => calls.push('job3')
|
||||
job3.id = 1
|
||||
|
||||
queueJob(job1)
|
||||
queueJob(job2)
|
||||
queueJob(job3)
|
||||
await nextTick()
|
||||
expect(calls).toEqual(['job3', 'job2', 'job1'])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user