less / less/less.js

Embedded JavaScript and strings

Open
#1,944 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug low priority needs decision
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

Strings returned from embedded JavaScript are handled differently when they are inside lists and out of them.

  • Escaped js removes quotes from returned strings whether they are inside the list or out of it.
  • Embedded js removes quotes from top level strings, but not from strings nested inside a list.
.strings {
  string-embedded: `'aaa'` `"bbb"`; 
  string-escaped: ~`'aaa'` ~`"bbb"`;
  strings-list-embedded: `['a', 'b', "c"]`;
  strings-list-escaped: ~`['a', 'b', "c"]`;
}

compiles into:

.strings {
  string-embedded: "aaa" "bbb";
  string-escaped: aaa bbb;
  strings-list-embedded: a, b, c;
  strings-list-escaped: a, b, c;
}

Is this how it is supposed to be? I am not sure how embedded js should really work. It make sense to strip them, because it is possible to add them from inside js and it would be impossible to return list of idents.

Then again, maybe 'aaa' "bbb" should not keep them there?

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.

Research direction

Start by reproducing the four embedded-JavaScript string examples from the issue in Less.js and compare top-level values with list elements. Read the handling of embedded and escaped JavaScript values, then clarify the intended quote behavior and make the results consistent across both contexts.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.