Skip to content

:global not working as nested selector #129

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
arxpoetica opened this issue May 19, 2021 · 10 comments
Closed

:global not working as nested selector #129

arxpoetica opened this issue May 19, 2021 · 10 comments

Comments

@arxpoetica
Copy link

arxpoetica commented May 19, 2021

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
Copy link
Member

ai commented May 19, 2021

What is Expected output?

@arxpoetica
Copy link
Author

Sorry updated.

@arxpoetica
Copy link
Author

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
Copy link
Member

ai commented May 19, 2021

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
Copy link
Author

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
Copy link
Member

ai commented May 19, 2021

Yeap. It could be related to #125

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

@ai
Copy link
Member

ai commented Jun 14, 2021

Should be fixed with PostCSS 8.3.3.

@ai ai closed this as completed Jun 14, 2021
@arxpoetica
Copy link
Author

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
Copy link
Member

ai commented Aug 22, 2021

Please create a new issue

@arxpoetica
Copy link
Author

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).

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

2 participants