From 9403228ed1bd72e4267cd618ec39b7c54c9c4457 Mon Sep 17 00:00:00 2001 From: daiwei Date: Fri, 3 Jan 2025 11:29:51 +0800 Subject: [PATCH] Revert "chore: update" This reverts commit 864273294f40153343c5bf224d878b0f2bc635af. --- packages/runtime-core/src/rendererTemplateRef.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/runtime-core/src/rendererTemplateRef.ts b/packages/runtime-core/src/rendererTemplateRef.ts index 062eaacae0e..5c3ab19db0a 100644 --- a/packages/runtime-core/src/rendererTemplateRef.ts +++ b/packages/runtime-core/src/rendererTemplateRef.ts @@ -13,12 +13,11 @@ import { isAsyncWrapper } from './apiAsyncComponent' import { warn } from './warning' import { isRef, toRaw } from '@vue/reactivity' import { ErrorCodes, callWithErrorHandling } from './errorHandling' -import { type SchedulerJob, SchedulerJobFlags } from './scheduler' +import type { SchedulerJob } from './scheduler' import { queuePostRenderEffect } from './renderer' import { type ComponentOptions, getComponentPublicInstance } from './component' import { knownTemplateRefs } from './helpers/useTemplateRef' -const pendingSetRef = new WeakMap() /** * Function for handling a template ref */ @@ -154,12 +153,13 @@ export function setRef( // #1789: for non-null values, set them after render // null values means this is unmount and it should not overwrite another // ref with the same key - ;(doSet as SchedulerJob).id = -1 - pendingSetRef.set(vnode, doSet) - queuePostRenderEffect(doSet, parentSuspense) + const job: SchedulerJob = () => { + if (!(vnode as any).__isUnmounting) doSet() + } + job.id = -1 + queuePostRenderEffect(job, parentSuspense) } else { - const pendingSet = pendingSetRef.get(vnode) - if (pendingSet) pendingSet.flags! |= SchedulerJobFlags.DISPOSED + ;(vnode as any).__isUnmounting = true doSet() } } else if (__DEV__) {