File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,18 @@ color: red
140
140
}
141
141
}"
142
142
` )
143
+ expect ( compileScoped ( `.foo { :deep(.bar) { color: red; }}` ) )
144
+ . toMatchInlineSnapshot ( `
145
+ ".foo {
146
+ &[data-v-test] .bar { color: red;
147
+ }}"
148
+ ` )
149
+ expect ( compileScoped ( `.foo { & :deep(.bar) { color: red; }}` ) )
150
+ . toMatchInlineSnapshot ( `
151
+ ".foo {
152
+ &[data-v-test] .bar { color: red;
153
+ }}"
154
+ ` )
143
155
} )
144
156
145
157
test ( '::v-slotted' , ( ) => {
Original file line number Diff line number Diff line change @@ -133,6 +133,29 @@ function rewriteSelector(
133
133
selector . insertAfter ( last , ss )
134
134
last = ss
135
135
} )
136
+
137
+ // if css nesting is used, we need to insert a nesting combinator
138
+ // before the ::v-deep node
139
+ // .foo { ::v-deep(.bar) } -> .foo { &[xxxxxxx] .bar }
140
+ const isNestedRule = rule . parent && rule . parent . type === 'rule'
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 ) {
154
+ node = selectorParser . nesting ( )
155
+ selector . insertBefore ( n , node )
156
+ }
157
+ }
158
+
136
159
// insert a space combinator before if it doesn't already have one
137
160
const prev = selector . at ( selector . index ( n ) - 1 )
138
161
if ( ! prev || ! isSpaceCombinator ( prev ) ) {
You can’t perform that action at this time.
0 commit comments