@@ -363,7 +363,7 @@ function baseCreateRenderer(
363
363
n1 = null
364
364
}
365
365
366
- const { type, shapeFlag } = n2
366
+ const { type, ref , shapeFlag } = n2
367
367
switch ( type ) {
368
368
case Text :
369
369
processText ( n1 , n2 , container , anchor )
@@ -439,6 +439,13 @@ function baseCreateRenderer(
439
439
warn ( 'Invalid VNode type:' , type , `(${ typeof type } )` )
440
440
}
441
441
}
442
+
443
+ // set ref
444
+ if ( ref != null && parentComponent ) {
445
+ const refValue =
446
+ shapeFlag & ShapeFlags . STATEFUL_COMPONENT ? n2 . component ! . proxy : n2 . el
447
+ setRef ( ref , n1 && n1 . ref , parentComponent , refValue )
448
+ }
442
449
}
443
450
444
451
const processText : ProcessTextOrCommentFn = ( n1 , n2 , container , anchor ) => {
@@ -518,9 +525,6 @@ function baseCreateRenderer(
518
525
} else {
519
526
patchElement ( n1 , n2 , parentComponent , parentSuspense , isSVG , optimized )
520
527
}
521
- if ( n2 . ref != null && parentComponent ) {
522
- setRef ( n2 . ref , n1 && n1 . ref , parentComponent , n2 . el )
523
- }
524
528
}
525
529
526
530
const mountElement = (
@@ -1005,17 +1009,6 @@ function baseCreateRenderer(
1005
1009
n2 . el = n1 . el
1006
1010
}
1007
1011
}
1008
- if ( n2 . ref != null && parentComponent ) {
1009
- if ( __DEV__ && ! ( n2 . shapeFlag & ShapeFlags . STATEFUL_COMPONENT ) ) {
1010
- pushWarningContext ( n2 )
1011
- warn (
1012
- `Functional components do not support "ref" because they do not ` +
1013
- `have instances.`
1014
- )
1015
- popWarningContext ( )
1016
- }
1017
- setRef ( n2 . ref , n1 && n1 . ref , parentComponent , n2 . component ! . proxy )
1018
- }
1019
1012
}
1020
1013
1021
1014
const mountComponent : MountComponentFn = (
0 commit comments