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

Nested selector redundancy on merge #1280

Closed
geedmo opened this issue Apr 17, 2013 · 5 comments
Closed

Nested selector redundancy on merge #1280

geedmo opened this issue Apr 17, 2013 · 5 comments

Comments

@geedmo
Copy link

geedmo commented Apr 17, 2013

Using nested selector, when merging it result in CSS with redundant declarations.

Example

.right {
  margin-left: 100%;
  .active {
    margin-left: 0;
  }
}
.bottom {
  margin-bottom: 100%;
  .active {
    margin-bottom: 0;
  }
}
/* merged */
.bottom-right { 
 .bottom;
 .right;
}

Generated code merges fine the parent selector rules, but nested selector has a redundant declaration

.right {
  margin-left: 100%;
}
.right .active {
  margin-left: 0;
}
.bottom {
  margin-bottom: 100%;
}
.bottom .active {
  margin-bottom: 0;
}
/* merged ok */
.bottom-right {
  margin-bottom: 100%;
  margin-left: 100%;
}
/* redundant */
.bottom-right .active {
  margin-bottom: 0;
}
.bottom-right .active {
  margin-left: 0;
}

Tested with all versions online at http://less2css.org/

@geedmo geedmo closed this as completed Apr 17, 2013
@geedmo geedmo reopened this Apr 17, 2013
@geedmo
Copy link
Author

geedmo commented May 12, 2013

Because there is no comments or ideas on this ..
The expected behavior should be

/* not redundant */
.bottom-right .active {
  margin-bottom: 0;
  margin-left: 0;
}

@lukeapage
Copy link
Member

work-around - use extend and that removes duplicates for properties

@lukeapage
Copy link
Member

This was a feature request on the css compressor I was looking at.. we could look at using that to simplify us having to do it (assuming we switch compressors and they implement)

@seven-phases-max
Copy link
Member

If I understand it right it's not really a bug (at least in context of today's Less approach). Either way, currently .bottom-right .active selectors will be merged with --clean-option=--advanced (--clean-css=--advanced in v2?) option so technically this has some chances to be closed (unless someone is going to implement some kind of deeper optimizations in the core itself in the foreseeable future).

@seven-phases-max
Copy link
Member

Oh wait, in fact it's just a duplicate of #930. So I'm closing this.

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

3 participants