Skip to content

Commit 540e26f

Browse files
committed
chore: only set slotted flag on sfc descriptor if style is scoped
1 parent ff4d4ec commit 540e26f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/compiler-sfc/__tests__/parse.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ h1 { color: red }
177177
.slotted
178178
).toBe(false)
179179
expect(
180-
parse(`<template>hi</template><style>:slotted(h1){color:red;}</style>`)
181-
.descriptor.slotted
180+
parse(
181+
`<template>hi</template><style scoped>:slotted(h1){color:red;}</style>`
182+
).descriptor.slotted
182183
).toBe(true)
183184
expect(
184-
parse(`<template>hi</template><style>::v-slotted(h1){color:red;}</style>`)
185-
.descriptor.slotted
185+
parse(
186+
`<template>hi</template><style scoped>::v-slotted(h1){color:red;}</style>`
187+
).descriptor.slotted
186188
).toBe(true)
187189
})
188190

packages/compiler-sfc/src/parse.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ export function parse(
237237

238238
// check if the SFC uses :slotted
239239
const slottedRE = /(?:::v-|:)slotted\(/
240-
descriptor.slotted = descriptor.styles.some(s => slottedRE.test(s.content))
240+
descriptor.slotted = descriptor.styles.some(
241+
s => s.scoped && slottedRE.test(s.content)
242+
)
241243

242244
const result = {
243245
descriptor,

0 commit comments

Comments
 (0)