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

Function parseCssVars

packages/compiler-sfc/src/style/cssVars.ts:66–85  ·  view source on GitHub ↗
(sfc: SFCDescriptor)

Source from the content-addressed store, hash-verified

64const vBindRE = /v-bind\s*\(/g
65
66export function parseCssVars(sfc: SFCDescriptor): string[] {
67 const vars: string[] = []
68 sfc.styles.forEach(style => {
69 let match
70 // ignore v-bind() in comments, eg /* ... */
71 // and // (Less, Sass and Stylus all support the use of // to comment)
72 const content = style.content.replace(/\/\*([\s\S]*?)\*\/|\/\/.*/g, '')
73 while ((match = vBindRE.exec(content))) {
74 const start = match.index + match[0].length
75 const end = lexBinding(content, start)
76 if (end !== null) {
77 const variable = normalizeExpression(content.slice(start, end))
78 if (!vars.includes(variable)) {
79 vars.push(variable)
80 }
81 }
82 }
83 })
84 return vars
85}
86
87enum LexerState {
88 inParens,

Callers 1

parseFunction · 0.90

Calls 4

lexBindingFunction · 0.85
normalizeExpressionFunction · 0.85
forEachMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected