Skip to content

Vue 3.5.15 changed CSS semantics when using CSS nesting and the > operator #13402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jessevanassen opened this issue May 28, 2025 · 2 comments
Closed

Comments

@jessevanassen
Copy link

jessevanassen commented May 28, 2025

Vue version

3.5.15

Link to minimal reproduction

https://play.vuejs.org/#eNp9UctOwzAQ/BXLR1RSodJLCZEA9VAOgICjJZQ62zSt47X8CEVV/521Q0oPVX2w1jOj2dn1nj8Yk3UB+IznHlqjSg+F0IzlVdMxqUrn7gVfIQpOsPDCR6JYMLfGoCq2BLZUAfJxRKNgqPLxiR09nf9RwJxEA1USZmTK9r1nwa6GUvhlKbe1xaCra4kK7Sx1uOvpQ8xGVz5OhgUfcU+metXU2cahpjnIiDHBJbamUWBfjW9QO8FnsQWjI3ipFH4/J8zbAKMBl2uQ2zP4xu0iJvibBQe2A8GPnC9tDb6n5x8vsKP6SLZYBUXqC+Q7OFQhZuxljzQ4xT7RpbSL1qD1ja4/3XznQbthqBg0LSXpBafPfLow+n/cSXb7t8wDbfGrAxs9aYGTbJrdTPnhF3n+tDs=

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 and div (.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 of 0-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.

@edison1105
Copy link
Member

duplicate of #13387

@skirtles-code
Copy link
Contributor

For the specificity issue, see also #13401.

I've created #13405 for further discussion of how to handle trailing * selectors. The conversation is currently spread across various issues and PRs and I think it would be better to gather thoughts in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants