-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 class as a mixin – unspecified behaviour
#2453
Comments
Notice the following example (logically equal to the one above) does not work at all regardless of the definition order:
So this is more like unspecified behaviour. P.S. |
@seven-phases-max but |
Not quite. It's only guaranteed to generate proper CSS selector. But re-use of CSS rulesets as mixins, especially when it comes to nesting and complex selector hierarchies, is relatively indirect/supplementary feature. (With certain limitations and possible contradictory requirements. After all even just the basic fact that Btw., regardless of above (this issue certainly needs some decision as of #1877/#2072), speaking of the use-cases: just out of curiosity, with this and the prev. issue you opened I see you're relying on that "CSS classes as mixins" stuff quite often, is there some special reason for this? The trick is that in today's Less state it's quite suspicious: from maintenance/development perspective/point-of-view this is usually not the best design (unless it's dictated by some external factors), usually |
Actually I got really excited when I first heard about .foo {
&:extend(.bar-baz);
}
.bar {
&-baz {
some: stuff;
}
} $ lessc this
.bar-baz {
some: stuff;
} Thank you for the advice regarding explicit mixins. I did consider that, but decided against at first. We have a fat CSS project (think Twitter Bootstrap) with a modular structure. The styles are often nested a couple of parent-selector levels deep, to keep things DRY. Every declaration belongs to a specific module. Other modules can help themselves by pulling that in and referencing it as a mixin. A module shouldn't care whether other modules need its declarations or not. I also want to keep declarations for a context directly in the context, without an additional abstraction in between. To avoid this: .text.bold {
.text-bold();
} That's theory. But after struggling with this for a while, I think I'll take your advice after all, until these decisions have been taken. And until #1177 is there. Thanks again :) |
Remarking it as a bug (after all recent discussions in various threads (e.g. #2072), a more strict "neither vars nor mixins should ever leak out of |
& {...}
nested class as a mixin – unspecified behaviour
This works as expected:
And that fails:
Funnily, it works when the declarations are the other way round:
I'm using
lessc 2.4.0 (Less Compiler) [JavaScript]
.The text was updated successfully, but these errors were encountered: