Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/compiler-sfc/__tests__/cssVars.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ describe('CSS vars injection', () => {
{ isProd: true },
)
expect(content).toMatch(`_useCssVars(_ctx => ({
"4003f1a6": (_ctx.color),
"41b6490a": (_ctx.font.size)
"v4003f1a6": (_ctx.color),
"v41b6490a": (_ctx.font.size)
}))}`)

const { code } = compileStyle({
Expand All @@ -124,8 +124,8 @@ describe('CSS vars injection', () => {
})
expect(code).toMatchInlineSnapshot(`
".foo {
color: var(--4003f1a6);
font-size: var(--41b6490a);
color: var(--v4003f1a6);
font-size: var(--v41b6490a);
}"
`)
})
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-sfc/src/style/cssVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function genVarName(
isSSR = false,
): string {
if (isProd) {
return hash(id + raw)
// hash must not start with a digit to comply with CSS custom property naming rules
return hash(id + raw).replace(/^\d/, r => `v${r}`)
} else {
// escape ASCII Punctuation & Symbols
// #7823 need to double-escape in SSR because the attributes are rendered
Expand Down
Loading