File tree Expand file tree Collapse file tree 2 files changed +30
-15
lines changed Expand file tree Collapse file tree 2 files changed +30
-15
lines changed Original file line number Diff line number Diff line change @@ -520,5 +520,12 @@ describe('SFC style preprocessors', () => {
520
520
"[data-v-test]:last-child [data-v-test]:active { color: red;
521
521
}"
522
522
` )
523
+ expect ( compileScoped ( `main { > * { background-color: yellow; } }` ) )
524
+ . toMatchInlineSnapshot ( `
525
+ "main {
526
+ > [data-v-test] { background-color: yellow;
527
+ }
528
+ }"
529
+ ` )
523
530
} )
524
531
} )
Original file line number Diff line number Diff line change @@ -255,6 +255,13 @@ function rewriteSelector(
255
255
)
256
256
shouldInject = false
257
257
}
258
+ } else {
259
+ // #13387 don't inject [id] at the selector start if node is null
260
+ // and the selector starts with `>`
261
+ const { type, value } = selector . first
262
+ if ( type === 'combinator' && value === '>' ) {
263
+ shouldInject = false
264
+ }
258
265
}
259
266
260
267
if ( node ) {
@@ -266,8 +273,8 @@ function rewriteSelector(
266
273
selector . first . spaces . before = ''
267
274
}
268
275
276
+ const idToAdd = slotted ? id + '-s' : id
269
277
if ( shouldInject ) {
270
- const idToAdd = slotted ? id + '-s' : id
271
278
selector . insertAfter (
272
279
// If node is null it means we need to inject [id] at the start
273
280
// insertAfter can handle `null` here
@@ -279,20 +286,21 @@ function rewriteSelector(
279
286
quoteMark : `"` ,
280
287
} ) ,
281
288
)
282
- // Used for trailing universal selectors (#12906)
283
- // `.foo * {}` -> `.foo[xxxxxxx] [xxxxxxx] {}`
284
- if ( starNode ) {
285
- selector . insertBefore (
286
- starNode ,
287
- selectorParser . attribute ( {
288
- attribute : idToAdd ,
289
- value : idToAdd ,
290
- raws : { } ,
291
- quoteMark : `"` ,
292
- } ) ,
293
- )
294
- selector . removeChild ( starNode )
295
- }
289
+ }
290
+
291
+ // Used for trailing universal selectors (#12906)
292
+ // `.foo * {}` -> `.foo[xxxxxxx] [xxxxxxx] {}`
293
+ if ( starNode ) {
294
+ selector . insertBefore (
295
+ starNode ,
296
+ selectorParser . attribute ( {
297
+ attribute : idToAdd ,
298
+ value : idToAdd ,
299
+ raws : { } ,
300
+ quoteMark : `"` ,
301
+ } ) ,
302
+ )
303
+ selector . removeChild ( starNode )
296
304
}
297
305
}
298
306
You can’t perform that action at this time.
0 commit comments