less / less/less.js

Collector variable structure if only one or zero arguments are collected

Open
#1,943 21 comments 0 reactions 1 assignee View on GitHub

@SomMeri is already working on this.

Since Feb 3, 2015.

bug consider closing medium priority
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

By collector variables I mean either @arguments variable or any mixin parameter declared with ....

If collector collected multiple values, then it contains a list. However, if it collected only on variable, then it does not contains a list. It contains that one variable. That makes it impossible to differentiate between these two things:

  • .mixin(1, 2, 3) // three parameters
  • .mixin(1, 2, 3;) // one parameter

Full test case:

.mixin(@first, @rest...) {
  rest-length: length(@rest);
  rest: ~`"@{rest}"`;
}

div-1 {
  .mixin(box-shadow 0.2s linear);
}
div-3 {
  .mixin(box-shadow 0.2s linear, color .4s .2s ease);
}
div-2 {
  .mixin(box-shadow 0.2s linear, color .4s .2s ease, jabba dabba);
}

current output:

div-1 {
  rest-length: 0;
  rest: ;
}
div-2 {
  rest-length: 4;
  rest: [color, 0.4s, 0.2s, ease];
}
div-2 {
  rest-length: 2;
  rest: [color 0.4s 0.2s ease, jabba dabba];
}

Expected output:

div-1 {
  rest-length: 0;
  rest: []; // maybe? 
}
div-2 {
 //here is difference. It is still impossible to tell comma/space difference, but 
 //it is at least possible to know the right number of parameters
  rest-length: 1;
  rest: [[color, 0.4s, 0.2s, ease]]; 
}
div-2 {
  rest-length: 2;
  rest: [[color, 0.4s, 0.2s, ease], [jabba dabba]];
}

Background: I was trying to find out how LessHat could work if we would fix #1939 (pull request #1941). Spaces/commas/argument separator difference is lost in less->js conversion. Which might be ok if would could partially deduce them from structure which is impossible.

LessHat current prints @arguments into string and then uses javascript to parse that string.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.