Skip to content

Commit 3227e50

Browse files
gucovipyyx990803
authored andcommitted
fix(compiler-sfc): support :is and :where selector in scoped css rewrite (#8929)
1 parent 3e08d24 commit 3227e50

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

+10
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ describe('SFC scoped CSS', () => {
8585
".baz .qux[data-v-test] .foo .bar { color: red;
8686
}"
8787
`)
88+
expect(compileScoped(`:is(.foo :deep(.bar)) { color: red; }`))
89+
.toMatchInlineSnapshot(`
90+
":is(.foo[data-v-test] .bar) { color: red;
91+
}"
92+
`)
93+
expect(compileScoped(`:where(.foo :deep(.bar)) { color: red; }`))
94+
.toMatchInlineSnapshot(`
95+
":where(.foo[data-v-test] .bar) { color: red;
96+
}"
97+
`)
8898
})
8999

90100
test('::v-slotted', () => {

packages/compiler-sfc/src/style/pluginScoped.ts

+5
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ function rewriteSelector(
173173
if (n.type !== 'pseudo' && n.type !== 'combinator') {
174174
node = n
175175
}
176+
177+
if (n.type === 'pseudo' && (n.value === ':is' || n.value === ':where')) {
178+
rewriteSelector(id, n.nodes[0], selectorRoot, slotted)
179+
shouldInject = false
180+
}
176181
})
177182

178183
if (node) {

0 commit comments

Comments
 (0)