@@ -147,7 +147,7 @@ export const TeleportImpl = {
147
147
}
148
148
if ( ! disabled ) {
149
149
mount ( target , targetAnchor )
150
- updateCssVars ( n2 )
150
+ updateCssVars ( n2 , false )
151
151
}
152
152
} else if ( __DEV__ && ! disabled ) {
153
153
warn (
@@ -160,7 +160,7 @@ export const TeleportImpl = {
160
160
161
161
if ( disabled ) {
162
162
mount ( container , mainAnchor )
163
- updateCssVars ( n2 )
163
+ updateCssVars ( n2 , true )
164
164
}
165
165
166
166
if ( isTeleportDeferred ( n2 . props ) ) {
@@ -267,7 +267,7 @@ export const TeleportImpl = {
267
267
)
268
268
}
269
269
}
270
- updateCssVars ( n2 )
270
+ updateCssVars ( n2 , disabled )
271
271
}
272
272
} ,
273
273
@@ -389,12 +389,13 @@ function hydrateTeleport(
389
389
querySelector ,
390
390
) )
391
391
if ( target ) {
392
+ const disabled = isTeleportDisabled ( vnode . props )
392
393
// if multiple teleports rendered to the same target element, we need to
393
394
// pick up from where the last teleport finished instead of the first node
394
395
const targetNode =
395
396
( target as TeleportTargetElement ) . _lpa || target . firstChild
396
397
if ( vnode . shapeFlag & ShapeFlags . ARRAY_CHILDREN ) {
397
- if ( isTeleportDisabled ( vnode . props ) ) {
398
+ if ( disabled ) {
398
399
vnode . anchor = hydrateChildren (
399
400
nextSibling ( node ) ,
400
401
vnode ,
@@ -446,7 +447,7 @@ function hydrateTeleport(
446
447
)
447
448
}
448
449
}
449
- updateCssVars ( vnode )
450
+ updateCssVars ( vnode , disabled )
450
451
}
451
452
return vnode . anchor && nextSibling ( vnode . anchor as Node )
452
453
}
@@ -462,13 +463,20 @@ export const Teleport = TeleportImpl as unknown as {
462
463
}
463
464
}
464
465
465
- function updateCssVars ( vnode : VNode ) {
466
+ function updateCssVars ( vnode : VNode , isDisabled : boolean ) {
466
467
// presence of .ut method indicates owner component uses css vars.
467
468
// code path here can assume browser environment.
468
469
const ctx = vnode . ctx
469
470
if ( ctx && ctx . ut ) {
470
- let node = vnode . targetStart
471
- while ( node && node !== vnode . targetAnchor ) {
471
+ let node , anchor
472
+ if ( isDisabled ) {
473
+ node = vnode . el
474
+ anchor = vnode . anchor
475
+ } else {
476
+ node = vnode . targetStart
477
+ anchor = vnode . targetAnchor
478
+ }
479
+ while ( node && node !== anchor ) {
472
480
if ( node . nodeType === 1 ) node . setAttribute ( 'data-v-owner' , ctx . uid )
473
481
node = node . nextSibling
474
482
}
0 commit comments