question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`:global` not working as nested selector

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
aicommented, Jun 14, 2021

Should be fixed with PostCSS 8.3.3.

0reactions
aicommented, Aug 22, 2021

Please create a new issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS :not() selector not working as expected (nested)
1. I think MDN is pretty clear on this point: "This selector only applies to one element; you cannot use it to exclude...
Read more >
Nested function not assigning value to global variable
You solve the problem most easily by not using globals at all. It is a bad idea to use globals in the first...
Read more >
Angular :host, :host-context, ::ng-deep - The Complete Guide
In this post, we will learn how the default Angular styling mechanism (Emulated Encapsulation) works under the hood, and we will also cover ......
Read more >
Nested Selectors - Emotion
Sometimes it's useful to nest selectors to target elements inside the current class or React component. An example with an element selector is...
Read more >
The benefits of nesting in LESS/SASS | by Vitaly Belman
In my experience however, nesting benefits outweigh the issues that were ... we should have global (not nested) selectors that define a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found