Skip to content

Commit 76132ef

Browse files
authored
Bug fixes - fixes #3446 #3368 (#3546)
* Fixes #3446 * Fixes #3368
1 parent ef4baa5 commit 76132ef

File tree

6 files changed

+61
-7
lines changed

6 files changed

+61
-7
lines changed

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"packages/*"
44
],
55
"npmClient": "npm",
6-
"version": "3.12.1"
6+
"version": "3.12.2"
77
}

packages/less/Gruntfile.js

+1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ module.exports = function(grunt) {
251251
command: [
252252
// @TODO: make this more thorough
253253
// CURRENT OPTIONS
254+
`node bin/lessc --ie-compat ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
254255
// --math
255256
`node bin/lessc --math=always ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
256257
`node bin/lessc --math=parens-division ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,

packages/less/bin/lessc

+4
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,10 @@ function processPluginQueue() {
516516
}
517517

518518
break;
519+
520+
case 'ie-compat':
521+
console.warn('The --ie-compat option is deprecated, as it has no effect on compilation.');
522+
break;
519523

520524
case 'relative-urls':
521525
console.warn('The --relative-urls option has been deprecated. Use --rewrite-urls=all.');

packages/less/src/less/functions/list.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Comment from '../tree/comment';
2+
import Node from '../tree/node';
23
import Dimension from '../tree/dimension';
34
import Declaration from '../tree/declaration';
45
import Expression from '../tree/expression';
@@ -65,20 +66,27 @@ export default {
6566
let newRules;
6667
let iterator;
6768

69+
const tryEval = val => {
70+
if (val instanceof Node) {
71+
return val.eval(this.context);
72+
}
73+
return val;
74+
};
75+
6876
if (list.value && !(list instanceof Quote)) {
6977
if (Array.isArray(list.value)) {
70-
iterator = list.value;
78+
iterator = list.value.map(tryEval);
7179
} else {
72-
iterator = [list.value];
80+
iterator = [tryEval(list.value)];
7381
}
7482
} else if (list.ruleset) {
75-
iterator = list.ruleset.rules;
83+
iterator = tryEval(list.ruleset).rules;
7684
} else if (list.rules) {
77-
iterator = list.rules;
85+
iterator = list.rules.map(tryEval);
7886
} else if (Array.isArray(list)) {
79-
iterator = list;
87+
iterator = list.map(tryEval);
8088
} else {
81-
iterator = [list];
89+
iterator = [tryEval(list)];
8290
}
8391

8492
let valueName = '@value';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
:root {
2+
--background-color: black;
3+
--color: #fff;
4+
}
5+
div {
6+
display: inline-block;
7+
padding: 1rem;
8+
background-color: var(--background-color);
9+
color: var(--color);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// see: https://github.com/less/less.js/issues/3368
2+
@vars: {
3+
background-color: black;
4+
color: contrast($background-color, #000, #fff);
5+
}
6+
7+
:root {
8+
each(@vars, {
9+
--@{key}: @value;
10+
});
11+
}
12+
13+
div {
14+
display: inline-block;
15+
padding: 1rem;
16+
background-color: var(--background-color);
17+
color: var(--color);
18+
}
19+
20+
// see: https://github.com/less/less.js/issues/3339
21+
// still fails - move to 4.0
22+
// @components: {
23+
// columns: true;
24+
// ratios: false;
25+
// };
26+
27+
// each(@components, {
28+
// & when (@value = true) {
29+
// @import (optional) "components/@{key}.less";
30+
// }
31+
// });

0 commit comments

Comments
 (0)