]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): properly rewrite :is with non-pseudo selector
authordaiwei <daiwei521@126.com>
Wed, 23 Oct 2024 10:01:30 +0000 (18:01 +0800)
committerdaiwei <daiwei521@126.com>
Wed, 23 Oct 2024 10:01:30 +0000 (18:01 +0800)
packages/compiler-sfc/__tests__/compileStyle.spec.ts
packages/compiler-sfc/src/style/pluginScoped.ts

index b76414364dc90f18bee19191fd6bda760d463f59..d6687a6b4d19a4fb907624b14ff57e37a3f19d46 100644 (file)
@@ -243,6 +243,12 @@ color: red
     }
     .div[data-v-test]:is(.foo:hover) { color: blue;
     }"`)
+
+    expect(compileScoped(`#app :is(.foo) { color: red; }`))
+      .toMatchInlineSnapshot(`
+      "#app :is(.foo[data-v-test]) { color: red;
+      }"
+    `)
   })
 
   test('media query', () => {
index b0224cf20d8eea0088f08dab8f426bf41149fa97..130ea1e3c7507e2f50ccbe8bc44741c43cabf340 100644 (file)
@@ -225,7 +225,7 @@ function rewriteSelector(
       (n.type !== 'pseudo' && n.type !== 'combinator') ||
       (n.type === 'pseudo' &&
         (n.value === ':is' || n.value === ':where') &&
-        !node)
+        (!node || !n.nodes.some(n => n.nodes.some(x => x.type === 'pseudo'))))
     ) {
       node = n
     }