postcss / postcss-nested

PostCSS plugin to unwrap nested rules like how Sass does it.
MIT License
1.15k stars 66 forks source link

`:global` not working as nested selector #129

Closed arxpoetica closed 3 years ago

arxpoetica commented 3 years ago

I use postcss-nested with postcss-global-nested, putting nested before the global nested plugin (in order).

This works in v4+ of postcss-nested and v5.0.1 but not in 5.0.0 or 5.0.2+.

Given:

.selector {
    :global {
        h2 {
            color: pink;
        }
    }
}

Expected:

.selector :global h2 {
    color: pink;
}

Actual:

.selector :global {
    h2 {
        color: pink;
    }
}

It's a little baffling, because both 5.0.1 and 5.0.2 are putting out

and

css: '.selector :global h2 {\n' +
    '\t\t\tcolor: pink;\n' +
    '\t\t}\n',

So... 🤷‍♂️

Happy to put together a repro if needed.

ai commented 3 years ago

What is Expected output?

arxpoetica commented 3 years ago

Sorry updated.

arxpoetica commented 3 years ago

Honestly, I think I'll need to create a repro. The behavior is really strange. I'll see if I can throw something together over the weekend.

ai commented 3 years ago

I never thought that it worked like this. Seems like it was non predicted feature.

Do you have reasons why it expected and should work?

arxpoetica commented 3 years ago

I'm a mess, lol. I STILL had it wrong above. I've fixed it (again), but for redundancy's sake, here's the correct again:

Expected:

.selector :global h2 {
    color: pink;
}

Actual:

.selector :global {
    h2 {
        color: pink;
    }
}

It's just not unfolding the nesting for anything past :global. There was another ticket about 3rd-level nestings, so it might be the same bug. I know this is working correctly on 5.0.1 but not on anything after.

ai commented 3 years ago

Yeap. It could be related to https://github.com/postcss/postcss-nested/issues/125

Somebody should debug and send PR, because I am right now on another project,

ai commented 3 years ago

Should be fixed with PostCSS 8.3.3.

arxpoetica commented 2 years ago

This is still an issue in the latest PostCSS (v 8.3.6). I'll have to create a small repo/repro to show it.

ai commented 2 years ago

Please create a new issue

arxpoetica commented 1 year ago

Years later...I've figured out this is a bug with https://github.com/a-x-/postcss-global-nested and not yous guys at all. They never updated to the PostCSS 8.0 API (https://evilmartians.com/chronicles/postcss-8-plugin-migration).