@@ -275,7 +275,8 @@ export const queuePostRenderEffect = __FEATURE_SUSPENSE__
275
275
export const setRef = (
276
276
rawRef : VNodeNormalizedRef ,
277
277
oldRawRef : VNodeNormalizedRef | null ,
278
- parent : ComponentInternalInstance ,
278
+ parentComponent : ComponentInternalInstance ,
279
+ parentSuspense : SuspenseBoundary | null ,
279
280
vnode : VNode | null
280
281
) => {
281
282
let value : ComponentPublicInstance | RendererNode | null
@@ -306,7 +307,9 @@ export const setRef = (
306
307
if ( isString ( oldRef ) ) {
307
308
refs [ oldRef ] = null
308
309
if ( hasOwn ( setupState , oldRef ) ) {
309
- setupState [ oldRef ] = null
310
+ queuePostRenderEffect ( ( ) => {
311
+ setupState [ oldRef ] = null
312
+ } , parentSuspense )
310
313
}
311
314
} else if ( isRef ( oldRef ) ) {
312
315
oldRef . value = null
@@ -316,12 +319,17 @@ export const setRef = (
316
319
if ( isString ( ref ) ) {
317
320
refs [ ref ] = value
318
321
if ( hasOwn ( setupState , ref ) ) {
319
- setupState [ ref ] = value
322
+ queuePostRenderEffect ( ( ) => {
323
+ setupState [ ref ] = value
324
+ } , parentSuspense )
320
325
}
321
326
} else if ( isRef ( ref ) ) {
322
327
ref . value = value
323
328
} else if ( isFunction ( ref ) ) {
324
- callWithErrorHandling ( ref , parent , ErrorCodes . FUNCTION_REF , [ value , refs ] )
329
+ callWithErrorHandling ( ref , parentComponent , ErrorCodes . FUNCTION_REF , [
330
+ value ,
331
+ refs
332
+ ] )
325
333
} else if ( __DEV__ ) {
326
334
warn ( 'Invalid template ref type:' , value , `(${ typeof value } )` )
327
335
}
@@ -497,7 +505,7 @@ function baseCreateRenderer(
497
505
498
506
// set ref
499
507
if ( ref != null && parentComponent ) {
500
- setRef ( ref , n1 && n1 . ref , parentComponent , n2 )
508
+ setRef ( ref , n1 && n1 . ref , parentComponent , parentSuspense , n2 )
501
509
}
502
510
}
503
511
@@ -1868,7 +1876,7 @@ function baseCreateRenderer(
1868
1876
} = vnode
1869
1877
// unset ref
1870
1878
if ( ref != null && parentComponent ) {
1871
- setRef ( ref , null , parentComponent , null )
1879
+ setRef ( ref , null , parentComponent , parentSuspense , null )
1872
1880
}
1873
1881
1874
1882
if ( shapeFlag & ShapeFlags . COMPONENT_SHOULD_KEEP_ALIVE ) {
0 commit comments