File tree 1 file changed +7
-14
lines changed
packages/compiler-sfc/src/style
1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -134,23 +134,16 @@ function rewriteSelector(
134
134
last = ss
135
135
} )
136
136
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.
139
139
// .foo { ::v-deep(.bar) } -> .foo { &[xxxxxxx] .bar }
140
140
const isNestedRule = rule . parent && rule . parent . type === 'rule'
141
141
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 ) {
154
147
node = selectorParser . nesting ( )
155
148
selector . insertBefore ( n , node )
156
149
}
You can’t perform that action at this time.
0 commit comments