@@ -10,14 +10,16 @@ import {
1010 warn ,
1111 watch ,
1212} from '@vue/runtime-core'
13- import { NOOP , ShapeFlags } from '@vue/shared'
13+ import { NOOP , ShapeFlags , normalizeCssVarValue } from '@vue/shared'
1414
1515export const CSS_VAR_TEXT : unique symbol = Symbol ( __DEV__ ? 'CSS_VAR_TEXT' : '' )
1616/**
1717 * Runtime helper for SFC's CSS variable injection feature.
1818 * @private
1919 */
20- export function useCssVars ( getter : ( ctx : any ) => Record < string , string > ) : void {
20+ export function useCssVars (
21+ getter : ( ctx : any ) => Record < string , unknown > ,
22+ ) : void {
2123 if ( ! __BROWSER__ && ! __TEST__ ) return
2224
2325 const instance = getCurrentInstance ( )
@@ -64,7 +66,7 @@ export function useCssVars(getter: (ctx: any) => Record<string, string>): void {
6466 } )
6567}
6668
67- function setVarsOnVNode ( vnode : VNode , vars : Record < string , string > ) {
69+ function setVarsOnVNode ( vnode : VNode , vars : Record < string , unknown > ) {
6870 if ( __FEATURE_SUSPENSE__ && vnode . shapeFlag & ShapeFlags . SUSPENSE ) {
6971 const suspense = vnode . suspense !
7072 vnode = suspense . activeBranch !
@@ -94,13 +96,14 @@ function setVarsOnVNode(vnode: VNode, vars: Record<string, string>) {
9496 }
9597}
9698
97- function setVarsOnNode ( el : Node , vars : Record < string , string > ) {
99+ function setVarsOnNode ( el : Node , vars : Record < string , unknown > ) {
98100 if ( el . nodeType === 1 ) {
99101 const style = ( el as HTMLElement ) . style
100102 let cssText = ''
101103 for ( const key in vars ) {
102- style . setProperty ( `--${ key } ` , vars [ key ] )
103- cssText += `--${ key } : ${ vars [ key ] } ;`
104+ const value = normalizeCssVarValue ( vars [ key ] )
105+ style . setProperty ( `--${ key } ` , value )
106+ cssText += `--${ key } : ${ value } ;`
104107 }
105108 ; ( style as any ) [ CSS_VAR_TEXT ] = cssText
106109 }
0 commit comments