Skip to content

Commit

Permalink
fix(runtime-core/scheduler): invalidate job (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangmingshan committed Feb 11, 2020
1 parent f4c54a8 commit fe9da2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/runtime-core/__tests__/scheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,20 @@ describe('scheduler', () => {
const job2 = () => {
calls.push('job2')
}
// queue both jobs
const job3 = () => {
calls.push('job3')
}
const job4 = () => {
calls.push('job4')
}
// queue all jobs
queueJob(job1)
queueJob(job2)
queueJob(job3)
queuePostFlushCb(job4)
expect(calls).toEqual([])
await nextTick()
// job2 should be called only once
expect(calls).toEqual(['job1', 'job2'])
expect(calls).toEqual(['job1', 'job2', 'job3', 'job4'])
})
})
2 changes: 1 addition & 1 deletion packages/runtime-core/src/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function flushJobs(seen?: CountMap) {
if (__DEV__) {
seen = seen || new Map()
}
while ((job = queue.shift())) {
while ((job = queue.shift()) !== undefined) {
if (job === null) {
continue
}
Expand Down

0 comments on commit fe9da2d

Please sign in to comment.