less.js icon indicating copy to clipboard operation
less.js copied to clipboard

Can't apply mixin as varible from a namespace

Open ahultgren opened this issue 6 years ago • 1 comments

This might be related to https://github.com/less/less.js/issues/3405:

.mix (@n) {
  value: @n;
}

@var: .mix(var);

#lookup {
  @var: .mix(lookup);
  @bar: bar;
}

.example {
  @var();
  value2: #lookup[@bar];

  // This is what I'm trying to do, since the above works:
  #lookup[@var]();
}

Expected:

.example {
  value: lookup;
  value2: bar;
}

Actual: unexpected token.

In this case I can't find a workaround using detached rulesets, but since @var() works I expect the nested syntax #lookup[@var]() to work as well.

ahultgren avatar Jul 16 '19 11:07 ahultgren

AFAIK this is simply an unsupported feature i.e. you can't call a mixin from a lookup. You need to alias it to a variable, as you mentioned.

matthew-dean avatar Jul 16 '19 17:07 matthew-dean