🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

less

Package Overview
Dependencies
Maintainers
5
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

less - npm Package Compare versions

Comparing version
4.8.0
to
4.8.1
+8
-1
lib/less/functions/math-helper.js
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 @@ }

+14
-13
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});

{
"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