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

Mixin in a namespace sometimes errors when referring to nested sibling mixin. #1410

Closed
Jimbly opened this issue Jul 9, 2013 · 1 comment
Closed

Comments

@Jimbly
Copy link

Jimbly commented Jul 9, 2013

This less code generates an error about ".sub is undefined":

.someclass { #namespace > .mixin(#F00); }
#namespace {
  .sub(@arg1) { background-color: @arg1; }
  .mixin(@color1) { .sub(@color1); }
}

But, none of the following do, which seems inconsistent. If the namespace is first, there is no error:

#namespace {
  .sub(@arg1) { background-color: @arg1; }
  .mixin(@color1) { .sub(@color1); }
}
.someclass { #namespace > .mixin(#F00); }

Or if the the error-generating mixin is moved out a scope level higher (but still later in the file):

.someclass { #namespace > .mixin(#F00); }
#namespace {
  .mixin(@color1) { .sub(@color1); }
}
.sub(@arg1) { background-color: @arg1; }

Or if it is referenced more explicitly:

.someclass { #namespace > .mixin(#F00); }
#namespace {
  .sub(@arg1) { background-color: @arg1; }
  .mixin(@color1) { #namespace > .sub(@color1); }
}

I could not find any reference in the documentation about whether or not order was required for mixins to work, though empirically it seems fine to reference a mixin defined after you reference it. It just seems to fail in this one case where referencing a mixin in a namespace which is referencing another mixin in the same namespace and all of this is after the first reference.

@SomMeri
Copy link
Member

SomMeri commented Jul 15, 2013

I think that this is duplicate of the #996 issue. The other one is labeled as a bug, but it is difficult to fix.

Solution for now is to define the namespace before using it. This works correctly:

#namespace {
  .sub(@arg1) { background-color: @arg1; }
  .mixin(@color1) { .sub(@color1); }
}
.someclass { #namespace > .mixin(#F00); }

I'm closing this as a duplicate. Leave the comment or re-open if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants