postcss / postcss-nested

PostCSS plugin to unwrap nested rules like how Sass does it.
MIT License
1.16k stars 67 forks source link

Ampersand & inside pseudo selectors :not() not resolved anymore #64

Closed troch closed 7 years ago

troch commented 7 years ago

Hi,

Use of & within pseudo selectors like :not is broken on v2. The following example:

.a {
    &:not(&--b) {
        display: none;
    }
}

On version 1.x, it was transformed to:

.a:not(.a--b) {
    display: none;
}

On version 2.x, it is transformed to:

.a:not(&--b) {
    display: none;
}
ai commented 7 years ago

Yeap, it is a bug. Thanks for the report. I will try to look at in tomorrow.

troch commented 7 years ago

Thanks!

ai commented 7 years ago

Done 1921ceb

ai commented 7 years ago

Released in 2.1.1

troch commented 7 years ago

Thanks a lot for the quick fix!

troch commented 7 years ago

@ai it appears the fix only works when there is one& in the rule.

The following works:

.component {
   :not(&--blue) {
      color: blue;
   }
}

But the following doesn't work

.component {
   &--highlighted:not(&--blue) {
      color: blue;
   }
}
ai commented 7 years ago

@troch will try to look in next days.

ai commented 7 years ago

Fixed bfc0b907b39b0114d2a32748097ed04a2f842592

ai commented 7 years ago

Released in 2.1.2

troch commented 7 years ago

All good, confirmed as fixed 👍

Thanks!