File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
packages/runtime-core/src Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,9 @@ export function setRef(
8181 } else {
8282 const _isString = isString ( ref )
8383 const _isRef = isRef ( ref )
84- const isVFor = rawRef . f
8584 if ( _isString || _isRef ) {
8685 const doSet = ( ) => {
87- if ( isVFor ) {
86+ if ( rawRef . f ) {
8887 const existing = _isString
8988 ? hasOwn ( setupState , ref )
9089 ? setupState [ ref ]
@@ -119,15 +118,14 @@ export function setRef(
119118 warn ( 'Invalid template ref type:' , ref , `(${ typeof ref } )` )
120119 }
121120 }
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
129125 ; ( doSet as SchedulerJob ) . id = - 1
130126 queuePostRenderEffect ( doSet , parentSuspense )
127+ } else {
128+ doSet ( )
131129 }
132130 } else if ( __DEV__ ) {
133131 warn ( 'Invalid template ref type:' , ref , `(${ typeof ref } )` )
You can’t perform that action at this time.
0 commit comments