| import Dimension from '../tree/dimension.js'; | ||
| const MathHelper = (fn, unit, n) => { | ||
| const MathHelper = (fn, unit, cssEvaluable, n) => { | ||
| if (!(n instanceof Dimension)) { | ||
| // A runtime CSS value such as var()/env() stays an unevaluated call and | ||
| // cannot be resolved to a number at compile time. Only functions with a | ||
| // CSS equivalent may be left for the browser; the rest (percentage, ceil, | ||
| // floor, round) have no CSS form and keep erroring on such input. | ||
| if (cssEvaluable && n && n.type === 'Call') { | ||
| return undefined; | ||
| } | ||
| throw { type: 'Argument', message: 'argument must be a number' }; | ||
@@ -6,0 +13,0 @@ } |
| import mathHelper from './math-helper.js'; | ||
| const mathFunctions = { | ||
| // name, unit | ||
| ceil: null, | ||
| floor: null, | ||
| sqrt: null, | ||
| abs: null, | ||
| tan: '', | ||
| sin: '', | ||
| cos: '', | ||
| atan: 'rad', | ||
| asin: 'rad', | ||
| acos: 'rad' | ||
| // name: [unit, has a CSS equivalent that the browser can evaluate] | ||
| ceil: [null, false], | ||
| floor: [null, false], | ||
| sqrt: [null, true], | ||
| abs: [null, true], | ||
| tan: ['', true], | ||
| sin: ['', true], | ||
| cos: ['', true], | ||
| atan: ['rad', true], | ||
| asin: ['rad', true], | ||
| acos: ['rad', true] | ||
| }; | ||
@@ -20,3 +20,4 @@ | ||
| if (mathFunctions.hasOwnProperty(f)) { | ||
| mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]); | ||
| const [unit, cssEvaluable] = mathFunctions[f]; | ||
| mathFunctions[f] = mathHelper.bind(null, Math[f], unit, cssEvaluable); | ||
| } | ||
@@ -27,5 +28,5 @@ } | ||
| const fraction = typeof f === 'undefined' ? 0 : f.value; | ||
| return mathHelper(num => num.toFixed(fraction), null, n); | ||
| return mathHelper(num => num.toFixed(fraction), null, false, n); | ||
| }; | ||
| export default mathFunctions; |
@@ -91,3 +91,3 @@ import Dimension from '../tree/dimension.js'; | ||
| percentage: function (n) { | ||
| const result = mathHelper(num => num * 100, '%', n); | ||
| const result = mathHelper(num => num * 100, '%', false, n); | ||
@@ -94,0 +94,0 @@ return result; |
@@ -154,2 +154,6 @@ // @ts-check | ||
| } | ||
| } else if (argValue.type === 'Expression' && Array.isArray(argValue.value) && argValue.value.length === 0) { | ||
| // an unset variadic holds no captured args; omit it so the callee | ||
| // falls through to its own parameter defaults instead of receiving empty | ||
| } else { | ||
@@ -156,0 +160,0 @@ args.push({name: arg.name, value: argValue}); |
+1
-1
| { | ||
| "name": "less", | ||
| "version": "4.8.0", | ||
| "version": "4.8.1", | ||
| "description": "Leaner CSS", | ||
@@ -5,0 +5,0 @@ "homepage": "http://lesscss.org", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
3187595
0.15%53801
0.07%18
-5.26%