Skip to content

Commit 8642732

Browse files
committed
chore: update
1 parent ca052b8 commit 8642732

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/runtime-core/src/rendererTemplateRef.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import { isAsyncWrapper } from './apiAsyncComponent'
1313
import { warn } from './warning'
1414
import { isRef, toRaw } from '@vue/reactivity'
1515
import { ErrorCodes, callWithErrorHandling } from './errorHandling'
16-
import type { SchedulerJob } from './scheduler'
16+
import { type SchedulerJob, SchedulerJobFlags } from './scheduler'
1717
import { queuePostRenderEffect } from './renderer'
1818
import { type ComponentOptions, getComponentPublicInstance } from './component'
1919
import { knownTemplateRefs } from './helpers/useTemplateRef'
2020

21+
const pendingSetRef = new WeakMap<VNode, SchedulerJob>()
2122
/**
2223
* Function for handling a template ref
2324
*/
@@ -153,13 +154,12 @@ export function setRef(
153154
// #1789: for non-null values, set them after render
154155
// null values means this is unmount and it should not overwrite another
155156
// ref with the same key
156-
const job: SchedulerJob = () => {
157-
if (!(vnode as any).__isUnmounting) doSet()
158-
}
159-
job.id = -1
160-
queuePostRenderEffect(job, parentSuspense)
157+
;(doSet as SchedulerJob).id = -1
158+
pendingSetRef.set(vnode, doSet)
159+
queuePostRenderEffect(doSet, parentSuspense)
161160
} else {
162-
;(vnode as any).__isUnmounting = true
161+
const pendingSet = pendingSetRef.get(vnode)
162+
if (pendingSet) pendingSet.flags! |= SchedulerJobFlags.DISPOSED
163163
doSet()
164164
}
165165
} else if (__DEV__) {

0 commit comments

Comments
 (0)