"[data-v-test]:last-child [data-v-test]:active { color: red;
}"
`)
+ expect(compileScoped(`main { > * { background-color: yellow; } }`))
+ .toMatchInlineSnapshot(`
+ "main {
+ > [data-v-test] { background-color: yellow;
+ }
+ }"
+ `)
})
})
)
shouldInject = false
}
+ } else {
+ // #13387 don't inject [id] at the selector start if node is null
+ // and the selector starts with `>`
+ const { type, value } = selector.first
+ if (type === 'combinator' && value === '>') {
+ shouldInject = false
+ }
}
if (node) {
selector.first.spaces.before = ''
}
+ const idToAdd = slotted ? id + '-s' : id
if (shouldInject) {
- const idToAdd = slotted ? id + '-s' : id
selector.insertAfter(
// If node is null it means we need to inject [id] at the start
// insertAfter can handle `null` here
quoteMark: `"`,
}),
)
- // Used for trailing universal selectors (#12906)
- // `.foo * {}` -> `.foo[xxxxxxx] [xxxxxxx] {}`
- if (starNode) {
- selector.insertBefore(
- starNode,
- selectorParser.attribute({
- attribute: idToAdd,
- value: idToAdd,
- raws: {},
- quoteMark: `"`,
- }),
- )
- selector.removeChild(starNode)
- }
+ }
+
+ // Used for trailing universal selectors (#12906)
+ // `.foo * {}` -> `.foo[xxxxxxx] [xxxxxxx] {}`
+ if (starNode) {
+ selector.insertBefore(
+ starNode,
+ selectorParser.attribute({
+ attribute: idToAdd,
+ value: idToAdd,
+ raws: {},
+ quoteMark: `"`,
+ }),
+ )
+ selector.removeChild(starNode)
}
}