throw an error when the unit function is passed bad input. Fixes #1426
This commit is contained in:
Родитель
39b36d9cfc
Коммит
0465398ab6
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
.a {
|
||||
font-size: unit(80/16,rem);
|
||||
}
|
|
@ -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 }
|
Загрузка…
Ссылка в новой задаче