]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): ensure scheduler queue is always non-null (#2567)
authorunderfin <likui6666666@gmail.com>
Mon, 9 Nov 2020 14:19:32 +0000 (22:19 +0800)
committerGitHub <noreply@github.com>
Mon, 9 Nov 2020 14:19:32 +0000 (09:19 -0500)
fix https://github.com/vitejs/vite/issues/1021

packages/runtime-core/src/scheduler.ts

index 32fce93cc85b3556fc3a836591516a613fdaefb1..e2781f97e4d8b659a677336174faf1f600beeb65 100644 (file)
@@ -30,7 +30,7 @@ export type SchedulerCbs = SchedulerCb | SchedulerCb[]
 let isFlushing = false
 let isFlushPending = false
 
-const queue: (SchedulerJob | null)[] = []
+const queue: SchedulerJob[] = []
 let flushIndex = 0
 
 const pendingPreFlushCbs: SchedulerCb[] = []
@@ -87,7 +87,7 @@ function queueFlush() {
 export function invalidateJob(job: SchedulerJob) {
   const i = queue.indexOf(job)
   if (i > -1) {
-    queue[i] = null
+    queue.splice(i, 1)
   }
 }
 
@@ -205,9 +205,7 @@ function flushJobs(seen?: CountMap) {
   //    priority number)
   // 2. If a component is unmounted during a parent component's update,
   //    its update can be skipped.
-  // Jobs can never be null before flush starts, since they are only invalidated
-  // during execution of another flushed job.
-  queue.sort((a, b) => getId(a!) - getId(b!))
+  queue.sort((a, b) => getId(a) - getId(b))
 
   try {
     for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {