(sfc: SFCDescriptor)
| 64 | const vBindRE = /v-bind\s*\(/g |
| 65 | |
| 66 | export 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 | |
| 87 | enum LexerState { |
| 88 | inParens, |
no test coverage detected