Closed as duplicate of#13387
Closed as duplicate of#13387
Description
Vue version
3.5.15
Link to minimal reproduction
Steps to reproduce
In the reproduction, toggle between 3.5.14 and 3.5.15 to see the different behavior.
What is expected?
The div should have a blue background
What is actually happening?
The div doesn't have a background applied.
System Info
Any additional comments?
When the following CSS is written:
<style scoped>
.class {
> * {
background-color: blue;
}
}
</style>
It used to be compiled to the following, in Vue 3.5.14:
.class {
> *[data-v-7ba5bd90] {
background-color: blue;
}
}
In Vue 3.5.15, it is compiled to this instead:
.class {
[data-v-7ba5bd90]> [data-v-7ba5bd90] {
background-color: blue;
}
}
In practice, this results in two problems:
- It means this generated CSS expects one or more elements between the
.class
anddiv
(.class [data-v-7ba5bd90] > [data-v-7ba5bd90]
instead of.class > [data-v-7ba5bd90]
). - It causes a regression in specificity. Before, it had a specificity of
0-2-0
, due to the parent class and the generated[data-v-
attribute. Now, it has a specificity of0-3-0
due to the additional second attribute.
Workaround
Use & > *
instead of > *
. This compiles into the following, which is semantically the same to what it was in Vue 3.5.14:
.class {
&[data-v-7ba5bd90] > [data-v-7ba5bd90] {
background-color: blue;
}
}
The difference in specificity remains though.
Metadata
Metadata
Assignees
Labels
No labels