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

Function genCssVarsFromList

packages/compiler-sfc/src/style/cssVars.ts:17–34  ·  view source on GitHub ↗
(
  vars: string[],
  id: string,
  isProd: boolean,
  isSSR = false,
)

Source from the content-addressed store, hash-verified

15export const CSS_VARS_HELPER = `useCssVars`
16
17export function genCssVarsFromList(
18 vars: string[],
19 id: string,
20 isProd: boolean,
21 isSSR = false,
22): string {
23 return `{\n ${vars
24 .map(
25 key =>
26 // The `:` prefix here is used in `ssrRenderStyle` to distinguish whether
27 // a custom property comes from `ssrCssVars`. If it does, we need to reset
28 // its value to `initial` on the component instance to avoid unintentionally
29 // inheriting the same property value from a different instance of the same
30 // component in the outer scope.
31 `"${isSSR ? `:--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`,
32 )
33 .join(',\n ')}\n}`
34}
35
36function genVarName(
37 id: string,

Callers 2

doCompileTemplateFunction · 0.90
genCssVarsCodeFunction · 0.85

Calls 2

genVarNameFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected