-
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
.Mixin() within .Mixin results in error #413
Comments
Easy fix: use a different name ;-) |
Well, I'm trying to create the option of letting the user have an unsemantic ruleset if they'd like it and the unsemantic ruleset would have the same code in .container as the .container() mixin -- so changing the name isn't particularly an option (or "fix"). |
As the compiler sees it, they are the same. Classes in LESS are mixins, and mixins with no parameters are classes. |
I just ran into this same issue when parsing the .clearfix() mixin in bootstrap using lessc and nodejs(v0.58) I commented on their change that caused this, here: It would be nice if less.js at least gave a more descriptive error rather than just "undefined" when this happens. Or better yet, why not just create a hashmap to alias class names and mixins differently. |
+1 on this one. This is especially critical because this exact problem caused WEBrick to crash as well (trying to serve the less file through Rails' assets pipelines) |
I get an error with the following code: @direction: ltr;
.left(@v) when (@direction = ltr) { left: @v; }
.left(@v) when (@direction = rtl) { right: @v; }
.right(@v) when (@direction = ltr) { right: @v; }
.right(@v) when (@direction = rtl) { left: @v; }
.carousel-control {
/* ..css.. */
&.right {
.left(auto);
.right(15px);
}
} I don't want to change the mixin name because its a convention and maps one-to-one with the corresponding CSS property. I also can't change the class name because its a 3rd party framework (bootstrap), that I'm porting to RTL support. So I'm +1-ing it :) |
I just ran into this. I don't agree with the syntax in the documentation:
I think parametric mixins taking no arguments should be invoked as if they were a function. |
I'm planning on just fixing this so it won't recurse/pull in a mixin on the |
I don't agree with it but I'll take it over nothing. |
Can you explain / give an example of the different output you expect? On 2012-10-24, at 7:56 AM, Josh Olson notifications@github.com wrote: I just ran into this. I don't agree with the syntax in the documentation: .wrap () { pre { .wrap } I think parametric mixins taking no arguments should be invoked as if they — |
@MatthewDL, I would expect an error in the example provided in the documentation.
|
Ohhhh.... Yes, I get what you mean.
I think you make a good point, and I don't disagree, but it's unfortunately a breaking change. And changing the behavior I don't feel is advantageous enough to force that change. For now, I'd say just don't have mixin definitions clash with class definitions. It's documented well enough that currently, the parentheses are not required. Also, I wonder if this is a case for LESS to have "warnings" generated and not just errors. |
Having said that... I did just see @krulik's example. Hmm... @agatronic, your thoughts? |
@MatthewDL changing this is a massive breaking change.. lots of people rely on the parenthesis being optional. in @krulik's example it shouldn't match the mixin without parenthesis any more anyway because the agrument matching has changed. I agree it may be a good place for a warning, but we don't have a mechanism to give those at the moment. playing around with @krulik's example I still get issues.. will continue investigating. |
ok, now even this is fine.. so you would have to have 2 mixins without parameters (one with, one without
|
@agatronic +1 for addressing this. |
This is why I always make sure to call mixins with brackets even without arguments. That, or prefix them with an underscore to make it clear they're mixins. |
To reiterate what I said in #1007 (Assuming this can't be solved with scope checking) I feel this is suitable for a breaking change in LESS 1.4. Enforcing it in 1.3.2 might be pushing it seeing as it would be a point (point-point?) release as of right now. |
…SON variant is used and then either output directly or afterwards converted to XML, ref less#413
Less code like this:
... Results in an error when compiled. It seems to be because they share the same name, although they are different (one is a mixin with empty arguments and one is just a class).
I'm using the ruby less gem to compile on Ubuntu.
The text was updated successfully, but these errors were encountered: