diff --git a/packages/compiler-sfc/__tests__/parse.spec.ts b/packages/compiler-sfc/__tests__/parse.spec.ts index 95119fab..2c640853 100644 --- a/packages/compiler-sfc/__tests__/parse.spec.ts +++ b/packages/compiler-sfc/__tests__/parse.spec.ts @@ -177,12 +177,14 @@ h1 { color: red } .slotted ).toBe(false) expect( - parse(``) - .descriptor.slotted + parse( + `` + ).descriptor.slotted ).toBe(true) expect( - parse(``) - .descriptor.slotted + parse( + `` + ).descriptor.slotted ).toBe(true) }) diff --git a/packages/compiler-sfc/src/parse.ts b/packages/compiler-sfc/src/parse.ts index 98359491..df7059c1 100644 --- a/packages/compiler-sfc/src/parse.ts +++ b/packages/compiler-sfc/src/parse.ts @@ -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,