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

Function injectCssVars

packages/compiler-ssr/src/transforms/ssrInjectCssVars.ts:38–68  ·  view source on GitHub ↗
(node: RootNode | TemplateChildNode)

Source from the content-addressed store, hash-verified

36}
37
38function injectCssVars(node: RootNode | TemplateChildNode) {
39 if (
40 node.type === NodeTypes.ELEMENT &&
41 (node.tagType === ElementTypes.ELEMENT ||
42 node.tagType === ElementTypes.COMPONENT) &&
43 !findDir(node, 'for')
44 ) {
45 if (node.tag === 'suspense' || node.tag === 'Suspense') {
46 for (const child of node.children) {
47 if (
48 child.type === NodeTypes.ELEMENT &&
49 child.tagType === ElementTypes.TEMPLATE
50 ) {
51 // suspense slot
52 child.children.forEach(injectCssVars)
53 } else {
54 injectCssVars(child)
55 }
56 }
57 } else {
58 node.props.push({
59 type: NodeTypes.DIRECTIVE,
60 name: 'bind',
61 arg: undefined,
62 exp: createSimpleExpression(`_cssVars`, false),
63 modifiers: [],
64 loc: locStub,
65 })
66 }
67 }
68}

Callers 1

ssrInjectCssVarsFunction · 0.85

Calls 4

findDirFunction · 0.85
createSimpleExpressionFunction · 0.85
forEachMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected