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

scopeBehaviour: 'global' not remove :global() decl on rule #30

Open
futurist opened this issue May 31, 2016 · 7 comments
Open

scopeBehaviour: 'global' not remove :global() decl on rule #30

futurist opened this issue May 31, 2016 · 7 comments

Comments

@futurist
Copy link

When using scopeBehaviour: 'global' for below css rule:

body:global(.noselect){ user-select:none }

The :global part is not removed, which result in invalid css selector.

@madyankin
Copy link
Owner

You have to place a space before :global, like this: body :global(.noselect) { user-select:none }. Otherwise it will be processed as pseudo-class.

@futurist
Copy link
Author

tried place a space before :global, result is same. And it's really worked when no space, if I use behaviour local

@madyankin
Copy link
Owner

Oh, I've got it. I think, it's not a good idea to use :global when it's the default behaviour. Just write body .noselect { user-select:none }.

@futurist
Copy link
Author

It's a lib that may export to other one to test with no local names. And at the same time may included in a JS component with local names, which want keep .noselect as global.

Is it possible to keep a single copy of the source CSS? Just by switch scopeBehaviour?

@StarpTech
Copy link

StarpTech commented May 25, 2020

I can reproduce it.

:global .page {
  padding: 20px;
}

produces this in scopeBehaviour: local scope

.page {
  padding: 20px;
}

but this in scopeBehaviour: global scope.

:global .page {
  padding: 20px;
}

@DimmDell
Copy link

DimmDell commented Jun 11, 2021

Having the same issue: i have a plugin that adds :global(*someclass*) to some selectors in my postcss and these ":global"-s need to be removed later, but they don't, so styles break. Tried different combinations of parameters for modules, scopeBehaviour and autoModules, but nothing helped.

@mattxyzeth
Copy link

I was dealing with a similar issue. I noticed that the :global() was removed when used within a local class but not when used within an element selector like a or body. I removed the :global() wrapping from the class within those tags, and it compiled correctly. So it seems that if the parent is not transformed, there's no need to wrap a child in :global() if the desired result should be global.

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

5 participants