less 4.8.0 → 4.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/less-node.cjs +26 -18
- package/dist/less.cjs +26 -18
- package/dist/less.js +26 -18
- package/dist/less.min.js +2 -2
- package/dist/less.min.js.map +1 -1
- package/lib/less/functions/math-helper.js +8 -1
- package/lib/less/functions/math.js +14 -13
- package/lib/less/functions/number.js +1 -1
- package/lib/less/tree/mixin-call.js +4 -0
- package/package.json +1 -1
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import Dimension from '../tree/dimension.js';
|
|
2
2
|
|
|
3
|
-
const MathHelper = (fn, unit, n) => {
|
|
3
|
+
const MathHelper = (fn, unit, cssEvaluable, n) => {
|
|
4
4
|
if (!(n instanceof Dimension)) {
|
|
5
|
+
// A runtime CSS value such as var()/env() stays an unevaluated call and
|
|
6
|
+
// cannot be resolved to a number at compile time. Only functions with a
|
|
7
|
+
// CSS equivalent may be left for the browser; the rest (percentage, ceil,
|
|
8
|
+
// floor, round) have no CSS form and keep erroring on such input.
|
|
9
|
+
if (cssEvaluable && n && n.type === 'Call') {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
5
12
|
throw { type: 'Argument', message: 'argument must be a number' };
|
|
6
13
|
}
|
|
7
14
|
if (unit === null) {
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import mathHelper from './math-helper.js';
|
|
2
2
|
|
|
3
3
|
const mathFunctions = {
|
|
4
|
-
// name
|
|
5
|
-
ceil: null,
|
|
6
|
-
floor: null,
|
|
7
|
-
sqrt: null,
|
|
8
|
-
abs: null,
|
|
9
|
-
tan: '',
|
|
10
|
-
sin: '',
|
|
11
|
-
cos: '',
|
|
12
|
-
atan: 'rad',
|
|
13
|
-
asin: 'rad',
|
|
14
|
-
acos: 'rad'
|
|
4
|
+
// name: [unit, has a CSS equivalent that the browser can evaluate]
|
|
5
|
+
ceil: [null, false],
|
|
6
|
+
floor: [null, false],
|
|
7
|
+
sqrt: [null, true],
|
|
8
|
+
abs: [null, true],
|
|
9
|
+
tan: ['', true],
|
|
10
|
+
sin: ['', true],
|
|
11
|
+
cos: ['', true],
|
|
12
|
+
atan: ['rad', true],
|
|
13
|
+
asin: ['rad', true],
|
|
14
|
+
acos: ['rad', true]
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
for (const f in mathFunctions) {
|
|
18
18
|
// eslint-disable-next-line no-prototype-builtins
|
|
19
19
|
if (mathFunctions.hasOwnProperty(f)) {
|
|
20
|
-
|
|
20
|
+
const [unit, cssEvaluable] = mathFunctions[f];
|
|
21
|
+
mathFunctions[f] = mathHelper.bind(null, Math[f], unit, cssEvaluable);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
mathFunctions.round = (n, f) => {
|
|
25
26
|
const fraction = typeof f === 'undefined' ? 0 : f.value;
|
|
26
|
-
return mathHelper(num => num.toFixed(fraction), null, n);
|
|
27
|
+
return mathHelper(num => num.toFixed(fraction), null, false, n);
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export default mathFunctions;
|
|
@@ -151,6 +151,10 @@ class MixinCall extends Node {
|
|
|
151
151
|
for (m = 0; m < expandedValues.length; m++) {
|
|
152
152
|
args.push({value: expandedValues[m]});
|
|
153
153
|
}
|
|
154
|
+
} else if (argValue.type === 'Expression' && Array.isArray(argValue.value) && argValue.value.length === 0) {
|
|
155
|
+
// an unset variadic holds no captured args; omit it so the callee
|
|
156
|
+
// falls through to its own parameter defaults instead of receiving empty
|
|
157
|
+
|
|
154
158
|
} else {
|
|
155
159
|
args.push({name: arg.name, value: argValue});
|
|
156
160
|
}
|