@@ -766,18 +766,8 @@ function propHasMismatch(
766
766
}
767
767
}
768
768
769
- // eslint-disable-next-line no-restricted-syntax
770
- const root = instance ?. subTree
771
- if (
772
- vnode === root ||
773
- // eslint-disable-next-line no-restricted-syntax
774
- ( root ?. type === Fragment && ( root . children as VNode [ ] ) . includes ( vnode ) )
775
- ) {
776
- // eslint-disable-next-line no-restricted-syntax
777
- const cssVars = instance ?. getCssVars ?.( )
778
- for ( const key in cssVars ) {
779
- expectedMap . set ( `--${ key } ` , String ( cssVars [ key ] ) )
780
- }
769
+ if ( instance ) {
770
+ resolveCssVars ( instance , vnode , expectedMap )
781
771
}
782
772
783
773
if ( ! isMapEqual ( actualMap , expectedMap ) ) {
@@ -854,10 +844,8 @@ function toStyleMap(str: string): Map<string, string> {
854
844
const styleMap : Map < string , string > = new Map ( )
855
845
for ( const item of str . split ( ';' ) ) {
856
846
let [ key , value ] = item . split ( ':' )
857
- // eslint-disable-next-line no-restricted-syntax
858
- key = key ?. trim ( )
859
- // eslint-disable-next-line no-restricted-syntax
860
- value = value ?. trim ( )
847
+ key = key . trim ( )
848
+ value = value && value . trim ( )
861
849
if ( key && value ) {
862
850
styleMap . set ( key , value )
863
851
}
@@ -876,3 +864,26 @@ function isMapEqual(a: Map<string, string>, b: Map<string, string>): boolean {
876
864
}
877
865
return true
878
866
}
867
+
868
+ function resolveCssVars (
869
+ instance : ComponentInternalInstance ,
870
+ vnode : VNode ,
871
+ expectedMap : Map < string , string > ,
872
+ ) {
873
+ const root = instance . subTree
874
+ if (
875
+ instance . getCssVars &&
876
+ ( vnode === root ||
877
+ ( root &&
878
+ root . type === Fragment &&
879
+ ( root . children as VNode [ ] ) . includes ( vnode ) ) )
880
+ ) {
881
+ const cssVars = instance . getCssVars ( )
882
+ for ( const key in cssVars ) {
883
+ expectedMap . set ( `--${ key } ` , String ( cssVars [ key ] ) )
884
+ }
885
+ }
886
+ if ( vnode === root && instance . parent ) {
887
+ resolveCssVars ( instance . parent , instance . vnode , expectedMap )
888
+ }
889
+ }
0 commit comments