Skip to content

Mixin included in a class / referenced file outputs CSS regardless #1885

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

Closed
mikedidthis opened this issue Feb 18, 2014 · 4 comments
Closed

Comments

@mikedidthis
Copy link

Firstly thank you for continuing the effort with less.js!

I seem to be struggling with mixins inside a class pulled from a reference file.

Reference File

@import (reference) "base/_buttons";

.button-small {
    background: red;
    border-radius: 3px;
    .font-size(16,24):
}

Usage

.pages li a {
    &:extend( .button-small );
}

Output

.button-small,
.pages li a {
    font-size: 16px;
    line-height: 24px;
}
.pages li a {
    background: red;
    border-radius: 3px;
}

I expect the rules would be broken over two groups of properties. However, I didn't expect .button-small to be included.

If I don't reference .button-small at all, the output is as follows:

Output

.button-small {
    font-size: 16px;
    line-height: 24px;
}

Am I doing something wrong? Are reference files for styles only? Is this a bug?

Any help would be appreciated.

@seven-phases-max
Copy link
Member

Most likely a duplicate of #1851 unless some older Less version used (but it's hard to say for sure without knowing how and where the .font-size mixin is defined) .

@SomMeri
Copy link
Member

SomMeri commented Feb 18, 2014

I did not managed to reproduce your problem. This is my referenced file:

.button-small {
    background: red;
    border-radius: 3px;
    .font-size(16,24);
}

.font-size(@a, @b) {
  font-size: @a;
}

and this one references it:

@import (reference) "file.less";

.pages li a {
    &:extend( .button-small );
}

it outputs:

.pages li a {
  background: red;
  border-radius: 3px;
  font-size: 16;
}

I also tried to put .font-size mixin into main file and it did the same thing. What less.js version do you use? Did I misunderstood you?

@mikedidthis
Copy link
Author

Damn that is a fast response, thank you! @SomMeri has the same setup as myself (apart from the mixin), so I am going to blame my complicated mixin.

I will simplify the mixin, test, and close.

Again thank you so much for the super work!

@mikedidthis
Copy link
Author

Yep, its my mixin, I used & when in the wrong context.

Again thank you so much for the fast response!

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