]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: update edison/fix/deepNesting 13163/head
authordaiwei <daiwei521@126.com>
Sat, 5 Apr 2025 02:32:02 +0000 (10:32 +0800)
committerdaiwei <daiwei521@126.com>
Sat, 5 Apr 2025 02:51:50 +0000 (10:51 +0800)
packages/compiler-sfc/__tests__/compileStyle.spec.ts
packages/compiler-sfc/src/style/pluginScoped.ts

index ff5ca2a952d41d634bc2a392478507e5df98a660..48e6ea8c3e96d8d7ee37ded70a619f9552f4dbcb 100644 (file)
@@ -146,6 +146,12 @@ color: red
         &[data-v-test] .bar { color: red;
         }}"
       `)
+    expect(compileScoped(`.foo { :deep(.bar),:deep(.baz) { color: red; }}`))
+      .toMatchInlineSnapshot(`
+        ".foo {
+        &[data-v-test] .bar,&[data-v-test] .baz { color: red;
+        }}"
+      `)
     expect(compileScoped(`.foo { & :deep(.bar) { color: red; }}`))
       .toMatchInlineSnapshot(`
         ".foo {
index b0854a22e429b10c9b5234894443ded2063e7253..0c7f700e1335d25c05ed2a1fc765d4a482605cd0 100644 (file)
@@ -134,23 +134,16 @@ function rewriteSelector(
             last = ss
           })
 
-          // if css nesting is used, we need to insert a nesting combinator
-          // before the ::v-deep node
+          // if css nesting is used, we need to insert a nesting selector
+          // before the ::v-deep's inner selector.
           // .foo { ::v-deep(.bar) } -> .foo { &[xxxxxxx] .bar }
           const isNestedRule = rule.parent && rule.parent.type === 'rule'
           if (isNestedRule && n.parent) {
-            let hasNestingCombinator = false
-            let index = n.parent.index(n) - 1
-            while (index >= 0) {
-              const prev = n.parent.at(index)
-              if (!prev) break
-              if (prev.type === 'nesting') {
-                hasNestingCombinator = true
-                break
-              }
-              index--
-            }
-            if (!hasNestingCombinator) {
+            const hasNestingSelector = n.parent.nodes
+              .slice(0, n.parent.index(n))
+              .some(node => node.type === 'nesting')
+
+            if (!hasNestingSelector) {
               node = selectorParser.nesting()
               selector.insertBefore(n, node)
             }