From 540e26f49c09edf09b6a60ac2a978fdec52686bf Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 5 Mar 2021 17:46:37 -0500 Subject: [PATCH] chore: only set slotted flag on sfc descriptor if style is scoped --- packages/compiler-sfc/__tests__/parse.spec.ts | 10 ++++++---- packages/compiler-sfc/src/parse.ts | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) 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,