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

Cleaning up selectors when calling extend multiple times on same class? #2426

Closed
ghost opened this issue Jan 31, 2015 · 4 comments
Closed

Cleaning up selectors when calling extend multiple times on same class? #2426

ghost opened this issue Jan 31, 2015 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 31, 2015

Hi,

in my opinion this is not an issue when following some guidelines and avoid calling an extend multiple times. In plain CSS we used to avoid duplicate rules so why care less when using a preprocessor?

Anyway, I like extends (done right) ;) and I don't like people blaming the tool but we have discussion on Twitter about bloat from using extend.

Consider this code (which I did not write): ;)

.bar {
  a: b;
}
.foo {
  &:extend(.bar);
}
.norf, .foo {
  &:extend(.bar); 
  c: d;
}

.foo appears multiple times in the same selector group:

.bar,
.foo,
.norf,
.foo {
  a: b;
}
.norf,
.foo {
  c: d;
}

What do you think? Should LESS clean duplicate selectors or should it not to force DRY when writing:

.bar {
  a: b;
}
.foo, .norf {
  &:extend(.bar);
}
.foo {
  c: d;
}
@seven-phases-max
Copy link
Member

This particular example does not appear to be that bloat if you compare it to a result of inheriting some real project classes (for instance to inherit Bootstrap button you need something like :extend(.btn all) which will generate about hundred of new selectors you'll most likely never use ;)

@melbon
Copy link

melbon commented Jul 27, 2017

Any updates?

@stale
Copy link

stale bot commented Nov 24, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 24, 2017
@seven-phases-max
Copy link
Member

seven-phases-max commented Nov 24, 2017

Use CSS minifiers (most will optimize the example just fine).
I'm closing this in favour of #1468 (see also tickets referenced there for deeper insight on various pitfalls about automatic merging).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants