]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
Revert "fix(compiler-sfc): add scoping tag to trailing universal selector (#1…" ...
authoredison <daiwei521@126.com>
Thu, 29 May 2025 00:21:19 +0000 (08:21 +0800)
committerGitHub <noreply@github.com>
Thu, 29 May 2025 00:21:19 +0000 (08:21 +0800)
This reverts commit 949df808809fd7cccf7718797beab0654aa68302.

packages/compiler-sfc/__tests__/compileStyle.spec.ts
packages/compiler-sfc/src/style/pluginScoped.ts

index 70c6af557abb592445b1f1c08554923282bc22d0..78fd52425e8ffe7dfa30658c57f9d9e3aac9c689 100644 (file)
@@ -493,31 +493,7 @@ describe('SFC style preprocessors', () => {
       }"
     `)
     expect(compileScoped(`.foo * { color: red; }`)).toMatchInlineSnapshot(`
-      ".foo[data-v-test] [data-v-test] { color: red;
-      }"
-    `)
-    expect(compileScoped(`.foo :active { color: red; }`))
-      .toMatchInlineSnapshot(`
-      ".foo[data-v-test] :active { color: red;
-      }"
-    `)
-    expect(compileScoped(`.foo *:active { color: red; }`))
-      .toMatchInlineSnapshot(`
-      ".foo[data-v-test] [data-v-test]:active { color: red;
-      }"
-    `)
-    expect(compileScoped(`.foo * .bar { color: red; }`)).toMatchInlineSnapshot(`
-      ".foo * .bar[data-v-test] { color: red;
-      }"
-    `)
-    expect(compileScoped(`:last-child * { color: red; }`))
-      .toMatchInlineSnapshot(`
-      "[data-v-test]:last-child [data-v-test] { color: red;
-      }"
-    `)
-    expect(compileScoped(`:last-child *:active { color: red; }`))
-      .toMatchInlineSnapshot(`
-      "[data-v-test]:last-child [data-v-test]:active { color: red;
+      ".foo[data-v-test] * { color: red;
       }"
     `)
   })
index 4845d8eee39568b6e91aa49ece544740635ff7fe..d0aaddd7676ba41d59eb1ed8899718dcbb89f746 100644 (file)
@@ -102,7 +102,6 @@ function rewriteSelector(
   slotted = false,
 ) {
   let node: selectorParser.Node | null = null
-  let starNode: selectorParser.Node | null = null
   let shouldInject = !deep
   // find the last child node to insert attribute selector
   selector.each(n => {
@@ -217,21 +216,17 @@ function rewriteSelector(
           return false
         }
       }
-      // store the universal selector so it can be rewritten later
-      // .foo * -> .foo[xxxxxxx] [xxxxxxx]
-      starNode = n
+      // .foo * -> .foo[xxxxxxx] *
+      if (node) return
     }
 
     if (
-      (n.type !== 'pseudo' &&
-        n.type !== 'combinator' &&
-        n.type !== 'universal') ||
+      (n.type !== 'pseudo' && n.type !== 'combinator') ||
       (n.type === 'pseudo' &&
         (n.value === ':is' || n.value === ':where') &&
         !node)
     ) {
       node = n
-      starNode = null
     }
   })
 
@@ -279,20 +274,6 @@ function rewriteSelector(
         quoteMark: `"`,
       }),
     )
-    // Used for trailing universal selectors (#12906)
-    // `.foo * {}` -> `.foo[xxxxxxx] [xxxxxxx] {}`
-    if (starNode) {
-      selector.insertBefore(
-        starNode,
-        selectorParser.attribute({
-          attribute: idToAdd,
-          value: idToAdd,
-          raws: {},
-          quoteMark: `"`,
-        }),
-      )
-      selector.removeChild(starNode)
-    }
   }
 }