File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -109,8 +109,8 @@ describe('CSS vars injection', () => {
109109 { isProd : true } ,
110110 )
111111 expect ( content ) . toMatch ( `_useCssVars(_ctx => ({
112- "4003f1a6 ": (_ctx.color),
113- "41b6490a ": (_ctx.font.size)
112+ "v4003f1a6 ": (_ctx.color),
113+ "v41b6490a ": (_ctx.font.size)
114114}))}` )
115115
116116 const { code } = compileStyle ( {
@@ -124,8 +124,8 @@ describe('CSS vars injection', () => {
124124 } )
125125 expect ( code ) . toMatchInlineSnapshot ( `
126126 ".foo {
127- color: var(--4003f1a6 );
128- font-size: var(--41b6490a );
127+ color: var(--v4003f1a6 );
128+ font-size: var(--v41b6490a );
129129 }"
130130 ` )
131131 } )
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ function genVarName(
4040 isSSR = false ,
4141) : string {
4242 if ( isProd ) {
43- return hash ( id + raw )
43+ // hash must not start with a digit to comply with CSS custom property naming rules
44+ return hash ( id + raw ) . replace ( / ^ \d / , r => `v${ r } ` )
4445 } else {
4546 // escape ASCII Punctuation & Symbols
4647 // #7823 need to double-escape in SSR because the attributes are rendered
You can’t perform that action at this time.
0 commit comments