-
Notifications
You must be signed in to change notification settings - Fork 4
postcss-nested-props breaks upon encountering :global or :local pseudo-selectors #9
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
Comments
@Kovensky, I've added a commit to #8 that should be published in a week or two, whenever TypeScript 2.0.1 is officially released (should be soon). I'll be unavailable this weekend, however, as I'll be flying to China during that time. |
Any chance this fix can get published? I'd like to use this plugin, but I'm using CSS Modules. |
Gotta' wait a few more days for postcss/postcss#950. Sorry for the long wait. I lost track of this one somehow. |
No worries. Thanks! |
@tomxtobin can you give v1.1.5 a try? |
Finally got a chance to test it out. It's still not working, unfortunately. I'm getting invalid CSS that's a little different than before: Instead, the final CSS output should be |
Do these two tests not represent the issue you have having? If not, can you write a failing test for me in the form of a PR? |
It needs to preserve all of these possible forms, in these contexts: .zeroOrMoreSelectors :global .oneOrMoreSelectors
.zeroOrMoreSelectors :local .oneOrMoreSelectors
.zeroOrMoreSelectors :global(.oneOrMoreSelectors) .zeroOrMoreSelectors
.zeroOrMoreSelectors :local(.oneOrMoreSelectors) .zeroOrMoreSelectors But sure, I can write a PR when I have a chance. |
Excellent, please do. I think it would add clarity to the exact scenarios in question. Also, if/when you do write the failing tests, try to keep it as simple as possible with |
@tomxtobin I've updated the dependencies, gutted gulp, introduced ava. It should be a bit easier for you to write tests now. |
@Kovensky, I've written a test, but it passes, so I can't reproduce your issue. Here's my test: test('preserves :global selector rule', scenario(
`:global .a{b:c;d:e;}`,
`:global .a{b:c;d:e;}`
)); Closing until I can get a breaking test. Otherwise, it might just be the order in which you're loading your PostCSS plugins. |
Uh oh!
There was an error while loading. Please reload this page.
Note that I've encountered this in combination with sugarss, which encourages the use of this transform. css-modules uses the
:global
and:local
pseudo-selectors to selectively disable/enable css-modules with the selectors nested within.The following sugarss:
Gets transformed into the following CSS:
The previous CSS, after running by postcss-nested-props, is transformed into the following invalid CSS, even though no nested props are present:
It seems to understand
:global
as being a nesting of "empty string" with the "global .selector" property name, which... makes very little sense.Is this intended to support a corner case where the caller specifies a prop value and nested props with the same prop declaration, without any whitespace? Perhaps it would be better to require whitespace before such a construct, specifically to prevent the syntactic ambiguity with pseudo-selectors and pseudo-elements. A regexp whitelist will always be a moving target, and will mysteriously cause breakages every time a new one is used.
The text was updated successfully, but these errors were encountered: