File tree 1 file changed +7
-9
lines changed
packages/runtime-core/src
1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,9 @@ export function setRef(
81
81
} else {
82
82
const _isString = isString ( ref )
83
83
const _isRef = isRef ( ref )
84
- const isVFor = rawRef . f
85
84
if ( _isString || _isRef ) {
86
85
const doSet = ( ) => {
87
- if ( isVFor ) {
86
+ if ( rawRef . f ) {
88
87
const existing = _isString
89
88
? hasOwn ( setupState , ref )
90
89
? setupState [ ref ]
@@ -119,15 +118,14 @@ export function setRef(
119
118
warn ( 'Invalid template ref type:' , ref , `(${ typeof ref } )` )
120
119
}
121
120
}
122
- // #9908 ref on v-for mutates the same array for both mount and unmount
123
- // and should be done together
124
- if ( isUnmount || isVFor ) {
125
- doSet ( )
126
- } else {
127
- // #1789: set new refs in a post job so that they don't get overwritten
128
- // by unmounting ones.
121
+ if ( value ) {
122
+ // #1789: for non-null values, set them after render
123
+ // null values means this is unmount and it should not overwrite another
124
+ // ref with the same key
129
125
; ( doSet as SchedulerJob ) . id = - 1
130
126
queuePostRenderEffect ( doSet , parentSuspense )
127
+ } else {
128
+ doSet ( )
131
129
}
132
130
} else if ( __DEV__ ) {
133
131
warn ( 'Invalid template ref type:' , ref , `(${ typeof ref } )` )
You can’t perform that action at this time.
0 commit comments