Skip to content

Commit af95604

Browse files
authored
fix(runtime-core): ensure scheduler queue is always non-null (#2567)
fix vitejs/vite#1021
1 parent b5926ff commit af95604

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/runtime-core/src/scheduler.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type SchedulerCbs = SchedulerCb | SchedulerCb[]
3030
let isFlushing = false
3131
let isFlushPending = false
3232

33-
const queue: (SchedulerJob | null)[] = []
33+
const queue: SchedulerJob[] = []
3434
let flushIndex = 0
3535

3636
const pendingPreFlushCbs: SchedulerCb[] = []
@@ -87,7 +87,7 @@ function queueFlush() {
8787
export function invalidateJob(job: SchedulerJob) {
8888
const i = queue.indexOf(job)
8989
if (i > -1) {
90-
queue[i] = null
90+
queue.splice(i, 1)
9191
}
9292
}
9393

@@ -205,9 +205,7 @@ function flushJobs(seen?: CountMap) {
205205
// priority number)
206206
// 2. If a component is unmounted during a parent component's update,
207207
// its update can be skipped.
208-
// Jobs can never be null before flush starts, since they are only invalidated
209-
// during execution of another flushed job.
210-
queue.sort((a, b) => getId(a!) - getId(b!))
208+
queue.sort((a, b) => getId(a) - getId(b))
211209

212210
try {
213211
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {

0 commit comments

Comments
 (0)