Skip to content
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

:global doesn't work with CSS nesting #12405

Open
GrantGryczan opened this issue Nov 15, 2024 · 3 comments · May be fixed by #12416
Open

:global doesn't work with CSS nesting #12405

GrantGryczan opened this issue Nov 15, 2024 · 3 comments · May be fixed by #12416
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: sfc

Comments

@GrantGryczan
Copy link

GrantGryczan commented Nov 15, 2024

Vue version

@d637bd6

Link to minimal reproduction

https://play.vuejs.org/#eNp9UctOwzAQ/BXLJ5BKqgpOIapEUQ9wAAQcfcljSdJuvJYfpVXVf2fjKLSHqJIvnhnvzKyP8smYZBdApjLz0BnMPSyVFiJrFssVVQdR5OW2thR0JVxDAStRgCgwwEx42Ptp3gRrEJJszlOUzuYXo/nq/AFBuJIMVIykNVKR403Bdrfi2Lufh96VhGTT6PjYvxaiWQyiKdlgzEIhTkrzyebRjW3kTHr21D9tnWwcaa4cxyhZUmdaBPtufEvaKZmOBkrmiPT7GjFvufSIlw2U2wl84/Y9puSHBQd2B0r+cz63NfiBXn+98fYuyI6qgKy+Qn6CIwx9xkG24uIc+0IX0750hqxvdf3t1nsP2o2l+qBxM1GvJP/785Xq57j3ycO4UXn6A8QMvRw=

Steps to reproduce

In the minimal reproduction, open the Playground's compiled CSS tab.

What is expected?

body {
  background-color: blue;
h1[data-v-7ba5bd90] {
    background-color: purple;
}
}

What is actually happening?

body {
&[data-v-7ba5bd90] {
  background-color: blue;
}
h1[data-v-7ba5bd90] {
    background-color: purple;
}
}

System Info

No response

Any additional comments?

Remove the nested h1 selector inside :global(body), and then the body's background becomes blue as expected.

@zh-lx
Copy link
Contributor

zh-lx commented Nov 15, 2024

The behavior of global and deep is not consistent with css nesting is really confusing. It seems a lot of people are confused by this issue: #12405104036587542051674533

I created a PR #10436 before to fix this issue but it wasn't accepted. Currently, nest css are supported support built-in, this scene will be used more and more. Maybe we should consider to reopen and accept #10436? @yyx990803 @edison1105

@edison1105
Copy link
Member

edison1105 commented Nov 15, 2024

@zh-lx
I think :global(.foo) .bar should compile to .foo .bar[data-v-xxx] instead of .foo .bar. If you want to get .foo .bar, write :global(.foo .bar). this is the expected behavior of #12404.

#10403 (comment)

@yyx990803
Copy link
Member

The repro here and #12404 are indeed both bugs. The expected output described by @GrantGryczan are correct in both cases. I don't think there is ambiguity here.

@yyx990803 yyx990803 added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. and removed need discussion labels Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: sfc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants