Skip to content

Commit afbda36

Browse files
committed
fix(compiler-sfc): properly rewrite :is with non-pseudo selector
1 parent ed01d92 commit afbda36

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ color: red
243243
}
244244
.div[data-v-test]:is(.foo:hover) { color: blue;
245245
}"`)
246+
247+
expect(compileScoped(`#app :is(.foo) { color: red; }`))
248+
.toMatchInlineSnapshot(`
249+
"#app :is(.foo[data-v-test]) { color: red;
250+
}"
251+
`)
246252
})
247253

248254
test('media query', () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function rewriteSelector(
225225
(n.type !== 'pseudo' && n.type !== 'combinator') ||
226226
(n.type === 'pseudo' &&
227227
(n.value === ':is' || n.value === ':where') &&
228-
!node)
228+
(!node || !n.nodes.some(n => n.nodes.some(x => x.type === 'pseudo'))))
229229
) {
230230
node = n
231231
}

0 commit comments

Comments
 (0)