mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Add tests for strict unit errors
This commit is contained in:
@@ -18,7 +18,7 @@ tree.Dimension.prototype = {
|
||||
},
|
||||
toCSS: function (env) {
|
||||
if ((!env || env.strictUnits !== false) && !this.unit.isSingular()) {
|
||||
throw new Error("multiple units in dimension: "+this.unit.toString());
|
||||
throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: "+this.unit.toString());
|
||||
}
|
||||
|
||||
var value = this.value,
|
||||
@@ -55,9 +55,9 @@ tree.Dimension.prototype = {
|
||||
} else {
|
||||
other = other.convertTo(this.unit.usedUnits());
|
||||
|
||||
if(env.strictUnits !== false && other.unit.toCSS() !== unit.toCSS()) {
|
||||
throw new Error("Incompatible units: '" + unit.toCSS() +
|
||||
"' and '" + other.unit.toCSS() + "'.");
|
||||
if(env.strictUnits !== false && other.unit.toString() !== unit.toString()) {
|
||||
throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '" + unit.toString() +
|
||||
"' and '" + other.unit.toString() + "'.");
|
||||
}
|
||||
|
||||
value = tree.operate(env, op, this.value, other.value);
|
||||
|
||||
Reference in New Issue
Block a user