File tree 1 file changed +9
-7
lines changed
packages/runtime-core/src
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -81,9 +81,10 @@ export function setRef(
81
81
} else {
82
82
const _isString = isString ( ref )
83
83
const _isRef = isRef ( ref )
84
+ const isVFor = rawRef . f
84
85
if ( _isString || _isRef ) {
85
86
const doSet = ( ) => {
86
- if ( rawRef . f ) {
87
+ if ( isVFor ) {
87
88
const existing = _isString
88
89
? hasOwn ( setupState , ref )
89
90
? setupState [ ref ]
@@ -118,14 +119,15 @@ export function setRef(
118
119
warn ( 'Invalid template ref type:' , ref , `(${ typeof ref } )` )
119
120
}
120
121
}
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
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.
125
129
; ( doSet as SchedulerJob ) . id = - 1
126
130
queuePostRenderEffect ( doSet , parentSuspense )
127
- } else {
128
- doSet ( )
129
131
}
130
132
} else if ( __DEV__ ) {
131
133
warn ( 'Invalid template ref type:' , ref , `(${ typeof ref } )` )
You can’t perform that action at this time.
0 commit comments