Browse Source

fix(compiler-sfc): ignore style v-bind in double slash comments (#5409)

Eavan 2 years ago
parent
commit
381b4977af
1 changed files with 3 additions and 2 deletions
  1. 3 2
      packages/compiler-sfc/src/style/cssVars.ts

+ 3 - 2
packages/compiler-sfc/src/style/cssVars.ts

@@ -53,8 +53,9 @@ export function parseCssVars(sfc: SFCDescriptor): string[] {
   const vars: string[] = []
   sfc.styles.forEach(style => {
     let match
-    // ignore v-bind() in comments /* ... */
-    const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '')
+    // ignore v-bind() in comments, eg /* ... */
+    // and // (Less, Sass and Stylus all support the use of // to comment)
+    const content = style.content.replace(/\/\*([\s\S]*?)\*\/|\/\/.*/g, '')
     while ((match = vBindRE.exec(content))) {
       const start = match.index + match[0].length
       const end = lexBinding(content, start)