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

Merge not working with :extend() #2130

Closed
d13 opened this issue Jul 30, 2014 · 4 comments
Closed

Merge not working with :extend() #2130

d13 opened this issue Jul 30, 2014 · 4 comments

Comments

@d13
Copy link

d13 commented Jul 30, 2014

When I use this LESS:

.error {
  background-color: #f00;
  color: #fff;
  box-shadow+: inset 0 0 0 1px #300;
}
.error-glowing {
  &:extend(.error all);
  box-shadow+: 0 0 10px 0 #d00;
}

I expect this:

.error {
  background-color: #f00;
  color: #fff;
  box-shadow: inset 0 0 0 1px #300;
}
.error-glowing {
  box-shadow: inset 0 0 0 1px #300, 0 0 10px 0 #d00;
}

The actual result is:

.error,
.error-glowing {
  background-color: #f00;
  color: #fff;
  box-shadow: inset 0 0 0 1px #300;
}
.error-glowing {
  box-shadow: 0 0 10px 0 #d00;
}

When I use .error like a mixin:

.error {
  background-color: #f00;
  color: #fff;
  box-shadow+: inset 0 0 0 1px #300;
}
.error-glowing {
  .error;
  box-shadow+: 0 0 10px 0 #d00;
}

It does the merge, but it has duplicate styles, of course:

.error {
  background-color: #f00;
  color: #fff;
  box-shadow: inset 0 0 0 1px #300;
}
.error-glowing {
  background-color: #f00;
  color: #fff;
  box-shadow: inset 0 0 0 1px #300, 0 0 10px 0 #d00;
}

Thanks.

@seven-phases-max
Copy link
Member

Well, this is kind of expected. Simply by definition, extend is supposed to affect only selectors without taking into account what actually is going on inside of the affected rulesets. So in short, if you use merge don't use extend and vice-versa.

Technically (if we consider this as a feature request), in theory it is possible to have some "more smart" extend-like feature that will analyse both extended and extending rulesets and cast mixin-like behaviour where necessary but I doubt we'll have anything like this any time soon. (I guess this idea has been already mentioned somewhere among those tens of extend dedicated threads, for example in #2095 -> route:2)

@d13
Copy link
Author

d13 commented Jul 31, 2014

Thought I'd throw it out there. Fortunately, there's a gazillion ways to skin a cat with LESS.

@lukeapage
Copy link
Member

If we implemented this I can see someone wanting a way to extend and not merge ..
It's a nice idea, but I think it's not worth it.

@seven-phases-max
Copy link
Member

OK, I guess we can close this for now as something that's barely to be considered to be implemented in the foreseeable future.

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