]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: add more tests
authordaiwei <daiwei521@126.com>
Tue, 20 May 2025 13:48:48 +0000 (21:48 +0800)
committerdaiwei <daiwei521@126.com>
Tue, 20 May 2025 13:48:48 +0000 (21:48 +0800)
packages/compiler-sfc/__tests__/compileStyle.spec.ts
packages/compiler-sfc/src/style/pluginScoped.ts

index d6687a6b4d19a4fb907624b14ff57e37a3f19d46..af8c874c5f55368c355f82f580a34127534811bd 100644 (file)
@@ -249,6 +249,24 @@ color: red
       "#app :is(.foo[data-v-test]) { color: red;
       }"
     `)
+
+    expect(compileScoped(`#app :is(:is(.foo)) { color: red; }`))
+      .toMatchInlineSnapshot(`
+        "#app :is(:is(.foo[data-v-test])) { color: red;
+        }"
+      `)
+
+    expect(compileScoped(`#app :where(.foo) { color: red; }`))
+      .toMatchInlineSnapshot(`
+      "#app :where(.foo[data-v-test]) { color: red;
+      }"
+    `)
+
+    expect(compileScoped(`#app :where(:where(.foo)) { color: red; }`))
+      .toMatchInlineSnapshot(`
+        "#app :where(:where(.foo[data-v-test])) { color: red;
+        }"
+      `)
   })
 
   test('media query', () => {
index 130ea1e3c7507e2f50ccbe8bc44741c43cabf340..375993479be5a9eb750ec5e01d3a65fe7f5af4dd 100644 (file)
@@ -225,7 +225,14 @@ function rewriteSelector(
       (n.type !== 'pseudo' && n.type !== 'combinator') ||
       (n.type === 'pseudo' &&
         (n.value === ':is' || n.value === ':where') &&
-        (!node || !n.nodes.some(n => n.nodes.some(x => x.type === 'pseudo'))))
+        (!node ||
+          n.nodes.some(
+            s =>
+              // has nested :is or :where
+              s.nodes.some(x => x.type === n.type && x.value === n.value) ||
+              // has non-pseudo selector
+              !s.nodes.some(x => x.type === 'pseudo'),
+          )))
     ) {
       node = n
     }