travco/postcss-extend

Extending class strings that contain, but don't start with, the extending class

timkelty opened this issue · 1 comments

.Foo {
  content: '.Foo';
}

.Foo.Bar {
  content: '.Foo.Bar';
}

.Foo .Bar {
  content: '.Foo .Bar';
}

.Bar .Foo {
  content: '.Bar .Foo';
}

.Bar.Foo {
  content: '.Bar.Foo';
}

.js .Foo {
  content: '.js .Foo';
}

.Bar {
  @extend .Foo;
}

Results:

.Foo, .Bar {
  content: '.Foo';
}

.Foo.Bar, .Bar.Bar {
  content: '.Foo.Bar';
}

.Foo .Bar, .Bar .Bar {
  content: '.Foo .Bar';
}

.Bar .Foo {
  content: '.Bar .Foo';
}

.Bar.Foo {
  content: '.Bar.Foo';
}

.js .Foo {
  content: '.js .Foo';
}

Notice how we don't get a .js .Bar, .Bar .Bar, or .Bar.Bar.
I'm pretty sure this is just an expected limitation of this implementation, but wan't to confirm.

Expected and intended limitation of the implementation. Mainly to keep extensions confined within the expected results of the programmer. Extensions only branch out if the base is matching.

If you need to extend things like .js .Foo you should be able to explictly call them out with @extend .js .Foo.