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 selector in css nesting #10721

Open
1 task
FrancoJavierGadea opened this issue Apr 9, 2024 · 1 comment
Open
1 task

:global selector in css nesting #10721

FrancoJavierGadea opened this issue Apr 9, 2024 · 1 comment
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@FrancoJavierGadea
Copy link

Astro Info

Astro                    v4.5.16
Node                     v20.11.0
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

This examples work fine

.container {

    & :global(h1) {

        color: #fff;
    }
}

/*Output css*/
.container[data-astro-cid-j7pv25f6] {
    & h1 {
        color: #fff;
    }
}
.container {

    & :global(h1) {
        color: #fff;
    }

    span {}
}

/*Output css*/
.container[data-astro-cid-j7pv25f6] {

    & h1 {
        color: #fff
    }

    span {}
}

This examples not work

.container {

    :global(h1) {

        color: #fff;
    }
}

/*Output css*/
.container[data-astro-cid-j7pv25f6] {
    :global(h1) {
        color: #fff;
    }
}
.container {

    span {}

    & :global(h1) {

        color: #fff;
    }
}

/*Output css*/
.container[data-astro-cid-j7pv25f6] {
    span {}

    & :global(h1) {
        color: #fff;
    }
}

What's the expected result?

.container {

    :global(h1) {

        color: #fff;
    }
}

/*Output css*/
.container[data-astro-cid-j7pv25f6] {
    h1 {
        color: #fff;
    }
}
.container {

    span {}

    & :global(h1) {

        color: #fff;
    }
}

/*Output css*/
.container[data-astro-cid-j7pv25f6] {
    span {}

    & h1 {
        color: #fff;
    }
}

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-8wzk1y?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 9, 2024
@bluwy
Copy link
Member

bluwy commented Apr 9, 2024

I'm not sure if this is a compiler issue since it may not handle CSS nesting syntax well. This problem should be able to be worked around by setting up postcss-nesting or postcss-nested in a postcss.config.cjs file though.

@matthewp matthewp added - P2: has workaround Bug, but has workaround (priority) and removed needs triage Issue needs to be triaged labels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

No branches or pull requests

3 participants