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

Custom selectors breaking #157

Closed
iamso opened this issue Oct 15, 2018 · 4 comments
Closed

Custom selectors breaking #157

iamso opened this issue Oct 15, 2018 · 4 comments

Comments

@iamso
Copy link

iamso commented Oct 15, 2018

Hi

while switching my project template from postcss-cssnext to postcss-preset-env I have discovered that custom selectors are not parsed correctly anymore.

Simple use cases still work, but if you add multiple custom selectors it starts getting weird.

I have posted this issue with postcss-preset-env and @jonathantneal suggested that the problem might be with this package.

Here is an example:

@custom-selector :--nav-open-header .site-loaded .nav-toggle-input:checked ~ .site-header;
@custom-selector :--nav-open-header-no-touch .site-loaded.no-touchevents .nav-toggle-input:checked ~ .site-header;

:--nav-open-header ul,
:--nav-open-header-no-touch:hover ul {
  background: red;
}

The expected output is this:

.site-loaded .nav-toggle-input:checked~.site-header ul,
.site-loaded .no-touchevents .nav-toggle-input:checked~.site-header:hover ul {
  background: red;
}

But what you get instead is this:

.site-loaded .nav-toggle-input:checked~.site-header ul,
.site-loaded
.no-touchevents 
.nav-toggle-input
:checked
~
.site-header:hover ul {
  background: red;
}

I have tested this example here https://preset-env.cssdb.org/playground and it behaves exactly as in my local setup.

As you can see, it breaks the :checked part of the selector and therefore it doesn't work.

It does work if you only use one, but with two, like in this example, it breaks the second one.

Thanks
Steve

@jonathantneal
Copy link
Member

jonathantneal commented Oct 19, 2018

Okay, I can verify the issue. The following CSS does work:

@custom-selector :--foobar .foo.bar;

:--foobar, a {
  background: red;
}

It becomes

.foo.bar, a {
  background: red;
}

While the following CSS does not work:

@custom-selector :--foobar .foo.bar;

a, :--foobar {
  background: red;
}

It instead becomes:

a, .foo .bar {
  background: red;
}

@alexander-akait
Copy link
Collaborator

@iamso @jonathantneal Based on tests #161 problem not in postcss-selector-parser

@jonathantneal
Copy link
Member

Since October, we have made many releases and perhaps this is resolved. If not, csstools/postcss-preset-env#89 can be re-opened.

@iamso
Copy link
Author

iamso commented Apr 13, 2019

@jonathantneal the issue is still not resolved

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

3 participants