]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: update
authordaiwei <daiwei521@126.com>
Fri, 3 Jan 2025 06:34:08 +0000 (14:34 +0800)
committerdaiwei <daiwei521@126.com>
Fri, 3 Jan 2025 06:34:08 +0000 (14:34 +0800)
packages/runtime-core/src/rendererTemplateRef.ts

index 5c3ab19db0a9a484a2e812a066d9cd5fc5376cd3..0e40c9534caf8af63c6e497bec22e68645c6c690 100644 (file)
@@ -13,11 +13,12 @@ import { isAsyncWrapper } from './apiAsyncComponent'
 import { warn } from './warning'
 import { isRef, toRaw } from '@vue/reactivity'
 import { ErrorCodes, callWithErrorHandling } from './errorHandling'
-import type { SchedulerJob } from './scheduler'
+import { type SchedulerJob, SchedulerJobFlags } from './scheduler'
 import { queuePostRenderEffect } from './renderer'
 import { type ComponentOptions, getComponentPublicInstance } from './component'
 import { knownTemplateRefs } from './helpers/useTemplateRef'
 
+const pendingSetRefMap = new WeakMap<VNode, SchedulerJob>()
 /**
  * Function for handling a template ref
  */
@@ -154,12 +155,18 @@ export function setRef(
         // null values means this is unmount and it should not overwrite another
         // ref with the same key
         const job: SchedulerJob = () => {
-          if (!(vnode as any).__isUnmounting) doSet()
+          doSet()
+          pendingSetRefMap.delete(vnode)
         }
         job.id = -1
+        pendingSetRefMap.set(vnode, job)
         queuePostRenderEffect(job, parentSuspense)
       } else {
-        ;(vnode as any).__isUnmounting = true
+        const pendingSetRef = pendingSetRefMap.get(vnode)
+        if (pendingSetRef) {
+          pendingSetRef.flags! |= SchedulerJobFlags.DISPOSED
+          pendingSetRefMap.delete(vnode)
+        }
         doSet()
       }
     } else if (__DEV__) {