Skip to content

Commit 8d9f49c

Browse files
committed
test: add more tests
1 parent afbda36 commit 8d9f49c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,24 @@ color: red
249249
"#app :is(.foo[data-v-test]) { color: red;
250250
}"
251251
`)
252+
253+
expect(compileScoped(`#app :is(:is(.foo)) { color: red; }`))
254+
.toMatchInlineSnapshot(`
255+
"#app :is(:is(.foo[data-v-test])) { color: red;
256+
}"
257+
`)
258+
259+
expect(compileScoped(`#app :where(.foo) { color: red; }`))
260+
.toMatchInlineSnapshot(`
261+
"#app :where(.foo[data-v-test]) { color: red;
262+
}"
263+
`)
264+
265+
expect(compileScoped(`#app :where(:where(.foo)) { color: red; }`))
266+
.toMatchInlineSnapshot(`
267+
"#app :where(:where(.foo[data-v-test])) { color: red;
268+
}"
269+
`)
252270
})
253271

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

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,14 @@ function rewriteSelector(
225225
(n.type !== 'pseudo' && n.type !== 'combinator') ||
226226
(n.type === 'pseudo' &&
227227
(n.value === ':is' || n.value === ':where') &&
228-
(!node || !n.nodes.some(n => n.nodes.some(x => x.type === 'pseudo'))))
228+
(!node ||
229+
n.nodes.some(
230+
s =>
231+
// has nested :is or :where
232+
s.nodes.some(x => x.type === n.type && x.value === n.value) ||
233+
// has non-pseudo selector
234+
!s.nodes.some(x => x.type === 'pseudo'),
235+
)))
229236
) {
230237
node = n
231238
}

0 commit comments

Comments
 (0)