]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: only set slotted flag on sfc descriptor if style is scoped
authorEvan You <yyx990803@gmail.com>
Fri, 5 Mar 2021 22:46:37 +0000 (17:46 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 5 Mar 2021 23:28:12 +0000 (18:28 -0500)
packages/compiler-sfc/__tests__/parse.spec.ts
packages/compiler-sfc/src/parse.ts

index 95119fab0547c054a470027c0b0ad08fe8f8a3b1..2c640853b1abb941be1b52e23979992791ce8503 100644 (file)
@@ -177,12 +177,14 @@ h1 { color: red }
         .slotted
     ).toBe(false)
     expect(
-      parse(`<template>hi</template><style>:slotted(h1){color:red;}</style>`)
-        .descriptor.slotted
+      parse(
+        `<template>hi</template><style scoped>:slotted(h1){color:red;}</style>`
+      ).descriptor.slotted
     ).toBe(true)
     expect(
-      parse(`<template>hi</template><style>::v-slotted(h1){color:red;}</style>`)
-        .descriptor.slotted
+      parse(
+        `<template>hi</template><style scoped>::v-slotted(h1){color:red;}</style>`
+      ).descriptor.slotted
     ).toBe(true)
   })
 
index 98359491a48688ec81dd962b2e0673646ab8363c..df7059c1f60632fe9f11fee667e6fb86f4cb4285 100644 (file)
@@ -237,7 +237,9 @@ export function parse(
 
   // check if the SFC uses :slotted
   const slottedRE = /(?:::v-|:)slotted\(/
-  descriptor.slotted = descriptor.styles.some(s => slottedRE.test(s.content))
+  descriptor.slotted = descriptor.styles.some(
+    s => s.scoped && slottedRE.test(s.content)
+  )
 
   const result = {
     descriptor,