@@ -13,11 +13,12 @@ import { isAsyncWrapper } from './apiAsyncComponent'
13
13
import { warn } from './warning'
14
14
import { isRef , toRaw } from '@vue/reactivity'
15
15
import { ErrorCodes , callWithErrorHandling } from './errorHandling'
16
- import type { SchedulerJob } from './scheduler'
16
+ import { type SchedulerJob , SchedulerJobFlags } from './scheduler'
17
17
import { queuePostRenderEffect } from './renderer'
18
18
import { type ComponentOptions , getComponentPublicInstance } from './component'
19
19
import { knownTemplateRefs } from './helpers/useTemplateRef'
20
20
21
+ const pendingSetRef = new WeakMap < VNode , SchedulerJob > ( )
21
22
/**
22
23
* Function for handling a template ref
23
24
*/
@@ -153,13 +154,12 @@ export function setRef(
153
154
// #1789: for non-null values, set them after render
154
155
// null values means this is unmount and it should not overwrite another
155
156
// 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 )
161
160
} else {
162
- ; ( vnode as any ) . __isUnmounting = true
161
+ const pendingSet = pendingSetRef . get ( vnode )
162
+ if ( pendingSet ) pendingSet . flags ! |= SchedulerJobFlags . DISPOSED
163
163
doSet ( )
164
164
}
165
165
} else if ( __DEV__ ) {
0 commit comments