mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
throw an error when the unit function is passed bad input. Fixes #1426
This commit is contained in:
@@ -233,6 +233,9 @@ tree.functions = {
|
||||
return new(tree.Quoted)('"' + str + '"', str);
|
||||
},
|
||||
unit: function (val, unit) {
|
||||
if(!(val instanceof tree.Dimension)) {
|
||||
throw { type: "Argument", message: "the first argument to unit must be a number" + (val instanceof tree.Operation ? ". Have you forgotten parenthesis?" : "") };
|
||||
}
|
||||
return new(tree.Dimension)(val.value, unit ? unit.toCSS() : "");
|
||||
},
|
||||
convert: function (val, unit) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var less = {};
|
||||
less.strictUnits = true;
|
||||
var less = {
|
||||
strictUnits: true,
|
||||
strictMath: true
|
||||
};
|
||||
|
||||
|
||||
3
test/less/errors/unit-function.less
Normal file
3
test/less/errors/unit-function.less
Normal file
@@ -0,0 +1,3 @@
|
||||
.a {
|
||||
font-size: unit(80/16,rem);
|
||||
}
|
||||
4
test/less/errors/unit-function.txt
Normal file
4
test/less/errors/unit-function.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
ArgumentError: error evaluating function `unit`: the first argument to unit must be a number. Have you forgotten parenthesis? in {path}unit-function.less on line 2, column 14:
|
||||
1 .a {
|
||||
2 font-size: unit(80/16,rem);
|
||||
3 }
|
||||
Reference in New Issue
Block a user