Skip to content

Commit

Permalink
Bug fixes - fixes #3446 #3368 (#3546)
Browse files Browse the repository at this point in the history
* Fixes #3446
* Fixes #3368
  • Loading branch information
matthew-dean authored Jul 29, 2020
1 parent ef4baa5 commit 76132ef
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"packages/*"
],
"npmClient": "npm",
"version": "3.12.1"
"version": "3.12.2"
}
1 change: 1 addition & 0 deletions packages/less/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ module.exports = function(grunt) {
command: [
// @TODO: make this more thorough
// CURRENT OPTIONS
`node bin/lessc --ie-compat ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
// --math
`node bin/lessc --math=always ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
`node bin/lessc --math=parens-division ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
Expand Down
4 changes: 4 additions & 0 deletions packages/less/bin/lessc
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ function processPluginQueue() {
}

break;

case 'ie-compat':
console.warn('The --ie-compat option is deprecated, as it has no effect on compilation.');
break;

case 'relative-urls':
console.warn('The --relative-urls option has been deprecated. Use --rewrite-urls=all.');
Expand Down
20 changes: 14 additions & 6 deletions packages/less/src/less/functions/list.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Comment from '../tree/comment';
import Node from '../tree/node';
import Dimension from '../tree/dimension';
import Declaration from '../tree/declaration';
import Expression from '../tree/expression';
Expand Down Expand Up @@ -65,20 +66,27 @@ export default {
let newRules;
let iterator;

const tryEval = val => {
if (val instanceof Node) {
return val.eval(this.context);
}
return val;
};

if (list.value && !(list instanceof Quote)) {
if (Array.isArray(list.value)) {
iterator = list.value;
iterator = list.value.map(tryEval);
} else {
iterator = [list.value];
iterator = [tryEval(list.value)];
}
} else if (list.ruleset) {
iterator = list.ruleset.rules;
iterator = tryEval(list.ruleset).rules;
} else if (list.rules) {
iterator = list.rules;
iterator = list.rules.map(tryEval);
} else if (Array.isArray(list)) {
iterator = list;
iterator = list.map(tryEval);
} else {
iterator = [list];
iterator = [tryEval(list)];
}

let valueName = '@value';
Expand Down
10 changes: 10 additions & 0 deletions packages/test-data/css/namespacing/namespacing-8.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:root {
--background-color: black;
--color: #fff;
}
div {
display: inline-block;
padding: 1rem;
background-color: var(--background-color);
color: var(--color);
}
31 changes: 31 additions & 0 deletions packages/test-data/less/namespacing/namespacing-8.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// see: https://github.com/less/less.js/issues/3368
@vars: {
background-color: black;
color: contrast($background-color, #000, #fff);
}

:root {
each(@vars, {
--@{key}: @value;
});
}

div {
display: inline-block;
padding: 1rem;
background-color: var(--background-color);
color: var(--color);
}

// see: https://github.com/less/less.js/issues/3339
// still fails - move to 4.0
// @components: {
// columns: true;
// ratios: false;
// };

// each(@components, {
// & when (@value = true) {
// @import (optional) "components/@{key}.less";
// }
// });

0 comments on commit 76132ef

Please sign in to comment.