@@ -73,6 +73,8 @@ import { type Block, normalizeBlock } from '../block'
7373import type { VaporElement } from '../apiDefineCustomElement'
7474import type { RootMeta } from './template'
7575import { isTransitionEnabled } from '../transition'
76+ import { isTeleportEnabled , isTeleportFragment } from '../teleport'
77+ import { isFragment } from '../fragment'
7678import { isInteropEnabled } from '../vdomInteropState'
7779import { currentRenderContext } from '../renderContext'
7880import { inOnce } from '../once'
@@ -982,8 +984,8 @@ function styleHasMismatch(
982984 expectedStyleMap . set ( 'display' , 'none' )
983985 }
984986
985- // handle css vars
986- if ( isVaporComponent ( instance ) ) {
987+ // handle css vars, which only dev builds expose
988+ if ( __DEV__ && isVaporComponent ( instance ) ) {
987989 resolveCssVars ( instance , el , expectedStyleMap )
988990 }
989991
@@ -1019,9 +1021,11 @@ function resolveCssVars(
10191021) : void {
10201022 if ( ! instance . isMounted ) return
10211023 const rootBlocks = normalizeBlock ( instance )
1024+ const nodes = normalizeBlock ( block )
1025+ const isRoot = nodes . every ( b => rootBlocks . includes ( b ) )
10221026 if (
10231027 ( instance as GenericComponentInstance ) . getCssVars &&
1024- normalizeBlock ( block ) . every ( b => rootBlocks . includes ( b ) )
1028+ ( isRoot || isTeleportRoot ( instance . block , nodes ) )
10251029 ) {
10261030 const cssVars = ( instance as GenericComponentInstance ) . getCssVars ! ( )
10271031 for ( const key in cssVars ) {
@@ -1030,10 +1034,7 @@ function resolveCssVars(
10301034 }
10311035 }
10321036
1033- if (
1034- normalizeBlock ( block ) . every ( b => rootBlocks . includes ( b ) ) &&
1035- instance . parent
1036- ) {
1037+ if ( isRoot && instance . parent ) {
10371038 if ( isVaporComponent ( instance . parent ) ) {
10381039 resolveCssVars ( instance . parent , instance . block , expectedMap )
10391040 } else if ( isInteropEnabled && instance . interopVNode ) {
@@ -1047,6 +1048,23 @@ function resolveCssVars(
10471048 }
10481049}
10491050
1051+ /**
1052+ * dev only. The roots of a teleport on the root chain carry the owner's css
1053+ * vars too.
1054+ */
1055+ function isTeleportRoot ( block : Block , nodes : Node [ ] ) : boolean {
1056+ if ( isArray ( block ) ) {
1057+ return block . some ( b => isTeleportRoot ( b , nodes ) )
1058+ }
1059+ if ( isTeleportEnabled && isTeleportFragment ( block ) ) {
1060+ const roots = normalizeBlock ( block . nodes )
1061+ return (
1062+ nodes . every ( n => roots . includes ( n ) ) || isTeleportRoot ( block . nodes , nodes )
1063+ )
1064+ }
1065+ return isFragment ( block ) && isTeleportRoot ( block . nodes , nodes )
1066+ }
1067+
10501068function attributeHasMismatch ( el : any , key : string , value : any ) : boolean {
10511069 if ( isValidHtmlOrSvgAttribute ( el , key ) ) {
10521070 const { actual, expected } = getAttributeMismatch ( el , key , value )
0 commit comments