Skip to content

Commit fe9da2d

Browse files
authored
fix(runtime-core/scheduler): invalidate job (#717)
1 parent f4c54a8 commit fe9da2d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/runtime-core/__tests__/scheduler.spec.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,20 @@ describe('scheduler', () => {
246246
const job2 = () => {
247247
calls.push('job2')
248248
}
249-
// queue both jobs
249+
const job3 = () => {
250+
calls.push('job3')
251+
}
252+
const job4 = () => {
253+
calls.push('job4')
254+
}
255+
// queue all jobs
250256
queueJob(job1)
251257
queueJob(job2)
258+
queueJob(job3)
259+
queuePostFlushCb(job4)
252260
expect(calls).toEqual([])
253261
await nextTick()
254262
// job2 should be called only once
255-
expect(calls).toEqual(['job1', 'job2'])
263+
expect(calls).toEqual(['job1', 'job2', 'job3', 'job4'])
256264
})
257265
})

packages/runtime-core/src/scheduler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function flushJobs(seen?: CountMap) {
7070
if (__DEV__) {
7171
seen = seen || new Map()
7272
}
73-
while ((job = queue.shift())) {
73+
while ((job = queue.shift()) !== undefined) {
7474
if (job === null) {
7575
continue
7676
}

0 commit comments

Comments
 (0)