Skip to content

Mixin parameteres used in guards on css selectors are considered undefined #1750

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
carlos22 opened this issue Dec 20, 2013 · 3 comments
Closed

Comments

@carlos22
Copy link

Example 1

.mixin(@colWidth) {

  // ugly inner mixin (works)
  .hide() when (@colWidth <= 0) {
    .inMixinCls {
      dispaly: none;
    }
  } 
  .hide();

}

.mixin(0px);

CSS:

.inMixinCls {
  dispaly: none;
}

Example 2:

.mixin(@colWidth) {

  // selector with guard (applies also to & when() ...)
  .clsWithGuard when (@colWidth <= 0) {
    dispaly: none;
  }

}

.mixin(0px);

Error

NameError: variable @colWidth is undefined in mixin-vars2.less on line 4, column 23:
3   // selector with guard (applies also to & when() ...)
4   .clsWithGuard when (@colWidth <= 0) {
5     dispaly: none;

I think example 2 should produce the same output as example 1?

Fun fact: Copy the variable into another in the current scope works.
Example:

.mixin(@colWidth) {

  // class with guard (applies also go & when() ...
  @colWidth2: @colWidth;
  .clsWithGuard when (@colWidth2 <= 0) {
    dispaly: none;
  }

}

.mixin(0px);
@seven-phases-max
Copy link
Member

See #1613 (not really a duplicate since there they assume that non-default value works, but apparently it also does not).

@StreetStrider
Copy link

Faced the same issue today. +1

@lukeapage
Copy link
Member

thanks for raising I hadn't realised what a bad issue this was. will be in a release this weekend.

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

4 participants