fix(ssr): forward helpers provided by CSS v-bind (#6489)

fix #6201
This commit is contained in:
Anthony Fu
2022-08-29 11:09:21 +08:00
committed by GitHub
parent 81a7819535
commit 2024d11db0
2 changed files with 27 additions and 1 deletions

View File

@@ -40,13 +40,17 @@ export function ssrCodegenTransform(ast: RootNode, options: CompilerOptions) {
// we do this instead of inlining the expression to ensure the vars are
// only resolved once per render
if (options.ssrCssVars) {
const cssContext = createTransformContext(createRoot([]), options)
const varsExp = processExpression(
createSimpleExpression(options.ssrCssVars, false),
createTransformContext(createRoot([]), options)
cssContext
)
context.body.push(
createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
)
Array.from(cssContext.helpers.keys()).forEach(helper =>
ast.helpers.push(helper)
)
}
const isFragment =