mirror of
https://github.com/less/less.js.git
synced 2026-02-09 22:45:28 -05:00
Improved min/max function, 2 new Built in function
max(0, 1em, 2, 4px) //returns 4px on the basis of first enter basis. Previous calculation would result in max(2, 1em, 4px). Here, 2 and 1em is compared, 2 is returned. then 2 and 4px is compared. Resulting in 4px. max(0, 1em, 1, 4px) //max(1em, 4px)
This commit is contained in:
@@ -276,29 +276,12 @@ tree.functions = {
|
||||
continue;
|
||||
}
|
||||
currentUnified = current.unify();
|
||||
unit = currentUnified.unit.toString();
|
||||
if(unit === "" && unitStatic !== undefined) {
|
||||
unit = unitStatic;
|
||||
} else if(unit === "") {
|
||||
unit = "variable";
|
||||
}
|
||||
unitStatic = unit !== "variable" && unitStatic === undefined ? unit : unitStatic;
|
||||
values[unit] = values["variable"] !== undefined && unit !== "variable" && unit === unitStatic ? values["variable"] : values[unit];
|
||||
unit = currentUnified.unit.toString() === "" && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
|
||||
unitStatic = unit !== "" && unitStatic === undefined || unit !== "" && order[0].unify().unit.toString() === "" ? unit : unitStatic;
|
||||
values[unit] = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit];
|
||||
j = values[unit];
|
||||
if (j === undefined) {
|
||||
values[unit] = order.length;
|
||||
//error handling for incompatible types
|
||||
if((values["px"] !== undefined && values["em"] !== undefined) || (values["px"] !== undefined && values["%"] !== undefined) ||
|
||||
(values["px"] !== undefined && values["m"] !== undefined) || (values["px"] !== undefined && values["s"] !== undefined) ||
|
||||
(values["px"] !== undefined && values["rad"] !== undefined) || (values["em"] !== undefined && values["%"] !== undefined) ||
|
||||
(values["em"] !== undefined && values["m"] !== undefined) || (values["em"] !== undefined && values["s"] !== undefined) ||
|
||||
(values["em"] !== undefined && values["rad"] !== undefined) || (values["%"] !== undefined && values["m"] !== undefined) ||
|
||||
(values["%"] !== undefined && values["s"] !== undefined) || (values["%"] !== undefined && values["rad"] !== undefined) ||
|
||||
(values["m"] !== undefined && values["s"] !== undefined) || (values["m"] !== undefined && values["rad"] !== undefined) ||
|
||||
(values["s"] !== undefined && values["rad"] !== undefined))
|
||||
{
|
||||
throw { type: "Argument", message: "incompatible types" };
|
||||
}
|
||||
order.push(current);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user