Skip to content

each() handles strings differently when length of list is 1 #3354

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
gweax opened this issue Jan 18, 2019 · 1 comment
Closed

each() handles strings differently when length of list is 1 #3354

gweax opened this issue Jan 18, 2019 · 1 comment
Assignees
Labels

Comments

@gweax
Copy link

gweax commented Jan 18, 2019

Short version: When a list of length 1 is passed and the list contains a string with quotes, the quotes are removed.

Long version: Consider this code:

.log(@msgs) {
  each(@msgs; {
    content: @value;
  }
}

@messages: 'foo', 'bar';

span {
  .log(@messages);
}

div {
  .log('foo');
}

The output is this:

span {
  content: 'foo';
  content: 'bar';
}

div {
  content: foo;
}

In the first example the quotes around the list items are preserved. In the second example, the quotes are removed.

I could get a consistent result by using the e() function to always remove the quotes, but in some cases I might want to keep them.

I created an estfiddle for the above code: http://ecomfe.github.io/est/fiddle/#code=LmxvZyhAbXNncykgewogICAgZWFjaChAbXNnczsgewogICAgICAgIGNvbnRlbnQ6IEB2YWx1ZTsKICAgIH0pOwp9CgpAbWVzc2FnZXM6ICdmb28nLCAnYmFyJzsKCnNwYW4gewogICAgLmxvZyhAbWVzc2FnZXMpOwp9CgpkaXYgewogICAgLmxvZygnZm9vJyk7Cn0K

@matthew-dean matthew-dean self-assigned this Feb 12, 2019
matthew-dean added a commit to matthew-dean/less.js that referenced this issue Feb 12, 2019
matthew-dean added a commit that referenced this issue Jul 11, 2019
* Don't escape quotes in an each #3354

* Fixes #3346 - ambiguous mixin call / color parsing

* Fixes #3338 - better error message

* Fixes #3338 - missed mix() function

* Fixes #3345
@matthew-dean
Copy link
Member

matthew-dean commented Jul 16, 2020

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

No branches or pull requests

2 participants