Преглед изворни кода

fix(compiler-sfc): properly rewrite universal selector scope

daiwei пре 1 година
родитељ
комит
34d02995ed

+ 1 - 1
packages/compiler-sfc/__tests__/compileStyle.spec.ts

@@ -489,7 +489,7 @@ describe('SFC style preprocessors', () => {
       }"
     `)
     expect(compileScoped(`.foo * { color: red; }`)).toMatchInlineSnapshot(`
-      ".foo[data-v-test] * { color: red;
+      ".foo *[data-v-test] { color: red;
       }"
     `)
   })

+ 6 - 2
packages/compiler-sfc/src/style/pluginScoped.ts

@@ -216,8 +216,12 @@ function rewriteSelector(
           return false
         }
       }
-      // .foo * -> .foo[xxxxxxx] *
-      if (node) return
+      // .foo * -> .foo *[xxxxxxx]
+      if (node) {
+        node = n
+        shouldInject = true
+        return
+      }
     }
 
     if (