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', () => {
109
109
{ isProd : true } ,
110
110
)
111
111
expect ( content ) . toMatch ( `_useCssVars(_ctx => ({
112
- "4003f1a6 ": (_ctx.color),
113
- "41b6490a ": (_ctx.font.size)
112
+ "v4003f1a6 ": (_ctx.color),
113
+ "v41b6490a ": (_ctx.font.size)
114
114
}))}` )
115
115
116
116
const { code } = compileStyle ( {
@@ -124,8 +124,8 @@ describe('CSS vars injection', () => {
124
124
} )
125
125
expect ( code ) . toMatchInlineSnapshot ( `
126
126
".foo {
127
- color: var(--4003f1a6 );
128
- font-size: var(--41b6490a );
127
+ color: var(--v4003f1a6 );
128
+ font-size: var(--v41b6490a );
129
129
}"
130
130
` )
131
131
} )
Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ function genVarName(
40
40
isSSR = false ,
41
41
) : string {
42
42
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 } ` )
44
45
} else {
45
46
// escape ASCII Punctuation & Symbols
46
47
// #7823 need to double-escape in SSR because the attributes are rendered
You can’t perform that action at this time.
0 commit comments