MCPcopy
hub / github.com/vuejs/core / ssrInjectCssVars

Function ssrInjectCssVars

packages/compiler-ssr/src/transforms/ssrInjectCssVars.ts:12–36  ·  view source on GitHub ↗
(node, context)

Source from the content-addressed store, hash-verified

10} from '@vue/compiler-dom'
11
12export const ssrInjectCssVars: NodeTransform = (node, context) => {
13 if (!context.ssrCssVars) {
14 return
15 }
16
17 // _cssVars is initialized once per render function
18 // the code is injected in ssrCodegenTransform when creating the
19 // ssr transform context
20 if (node.type === NodeTypes.ROOT) {
21 context.identifiers._cssVars = 1
22 }
23
24 const parent = context.parent
25 if (!parent || parent.type !== NodeTypes.ROOT) {
26 return
27 }
28
29 if (node.type === NodeTypes.IF_BRANCH) {
30 for (const child of node.children) {
31 injectCssVars(child)
32 }
33 } else {
34 injectCssVars(node)
35 }
36}
37
38function injectCssVars(node: RootNode | TemplateChildNode) {
39 if (

Callers

nothing calls this directly

Calls 1

injectCssVarsFunction · 0.85

Tested by

no test coverage detected