Skip to content

Commit bfd11af

Browse files
committed
chore: update
1 parent 6f0f944 commit bfd11af

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

packages/compiler-sfc/__tests__/compileStyle.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ color: red
146146
&[data-v-test] .bar { color: red;
147147
}}"
148148
`)
149+
expect(compileScoped(`.foo { :deep(.bar),:deep(.baz) { color: red; }}`))
150+
.toMatchInlineSnapshot(`
151+
".foo {
152+
&[data-v-test] .bar,&[data-v-test] .baz { color: red;
153+
}}"
154+
`)
149155
expect(compileScoped(`.foo { & :deep(.bar) { color: red; }}`))
150156
.toMatchInlineSnapshot(`
151157
".foo {

packages/compiler-sfc/src/style/pluginScoped.ts

+7-14
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,16 @@ function rewriteSelector(
134134
last = ss
135135
})
136136

137-
// if css nesting is used, we need to insert a nesting combinator
138-
// before the ::v-deep node
137+
// if css nesting is used, we need to insert a nesting selector
138+
// before the ::v-deep's inner selector.
139139
// .foo { ::v-deep(.bar) } -> .foo { &[xxxxxxx] .bar }
140140
const isNestedRule = rule.parent && rule.parent.type === 'rule'
141141
if (isNestedRule && n.parent) {
142-
let hasNestingCombinator = false
143-
let index = n.parent.index(n) - 1
144-
while (index >= 0) {
145-
const prev = n.parent.at(index)
146-
if (!prev) break
147-
if (prev.type === 'nesting') {
148-
hasNestingCombinator = true
149-
break
150-
}
151-
index--
152-
}
153-
if (!hasNestingCombinator) {
142+
const hasNestingSelector = n.parent.nodes
143+
.slice(0, n.parent.index(n))
144+
.some(node => node.type === 'nesting')
145+
146+
if (!hasNestingSelector) {
154147
node = selectorParser.nesting()
155148
selector.insertBefore(n, node)
156149
}

0 commit comments

Comments
 (0)