From: daiwei Date: Tue, 20 May 2025 13:48:48 +0000 (+0800) Subject: test: add more tests X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d9f49c9658370ad337a5a9ed327b1cb93cbbf55;p=thirdparty%2Fvuejs%2Fcore.git test: add more tests --- diff --git a/packages/compiler-sfc/__tests__/compileStyle.spec.ts b/packages/compiler-sfc/__tests__/compileStyle.spec.ts index d6687a6b4d..af8c874c5f 100644 --- a/packages/compiler-sfc/__tests__/compileStyle.spec.ts +++ b/packages/compiler-sfc/__tests__/compileStyle.spec.ts @@ -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', () => { diff --git a/packages/compiler-sfc/src/style/pluginScoped.ts b/packages/compiler-sfc/src/style/pluginScoped.ts index 130ea1e3c7..375993479b 100644 --- a/packages/compiler-sfc/src/style/pluginScoped.ts +++ b/packages/compiler-sfc/src/style/pluginScoped.ts @@ -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 }