src/sap.ui.core/src/sap/ui/thirdparty/less.js
function (env, op, other) {
        /*jshint noempty:false */
        var value = tree.operate(env, op, this.value, other.value),
            unit = this.unit.clone();

        if (op === '+' || op === '-') {
            if (unit.numerator.length === 0 && unit.denominator.length === 0) {
                unit.numerator = other.unit.numerator.slice(0);
                unit.denominator = other.unit.denominator.slice(0);
            } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) {
                // do nothing
            } else {
                other = other.convertTo(this.unit.usedUnits());

                if(env.strictUnits && 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);
            }
        } else if (op === '*') {
            unit.numerator = unit.numerator.concat(other.unit.numerator).sort();
            unit.denominator = unit.denominator.concat(other.unit.denominator).sort();
            unit.cancel();
        } else if (op === '/') {
            unit.numerator = unit.numerator.concat(other.unit.denominator).sort();
            unit.denominator = unit.denominator.concat(other.unit.numerator).sort();
            unit.cancel();
        }
        return new(tree.Dimension)(value, unit);
    }
function (env, op, other) {
        /*jshint noempty:false */
        var value = tree.operate(env, op, this.value, other.value),
            unit = this.unit.clone();

        if (op === '+' || op === '-') {
            if (unit.numerator.length === 0 && unit.denominator.length === 0) {
                unit.numerator = other.unit.numerator.slice(0);
                unit.denominator = other.unit.denominator.slice(0);
            } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) {
                // do nothing
            } else {
                other = other.convertTo(this.unit.usedUnits());

                if(env.strictUnits && 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);
            }
        } else if (op === '*') {
            unit.numerator = unit.numerator.concat(other.unit.numerator).sort();
            unit.denominator = unit.denominator.concat(other.unit.denominator).sort();
            unit.cancel();
        } else if (op === '/') {
            unit.numerator = unit.numerator.concat(other.unit.denominator).sort();
            unit.denominator = unit.denominator.concat(other.unit.numerator).sort();
            unit.cancel();
        }
        return new(tree.Dimension)(value, unit);
    }
function ( env , op , other ) { /*jshint noempty:false */ var value = tree . operate ( env , op , this . value , other . value ) , unit = this . unit . clone ( ) ; if ( op === '+' || op === '-' ) { if ( unit . numerator . length === 0 && unit . denominator . length === 0 ) { unit . numerator = other . unit . numerator . slice ( 0 ) ; unit . denominator = other . unit . denominator . slice ( 0 ) ; } else if ( other . unit . numerator . length === 0 && unit . denominator . length === 0 ) { // do nothing } else { other = other . convertTo ( this . unit . usedUnits ( ) ) ; if ( env . strictUnits && 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 ) ; } } else if ( op === '*' ) { unit . numerator = unit . numerator . concat ( other . unit . numerator ) . sort ( ) ; unit . denominator = unit . denominator . concat ( other . unit . denominator ) . sort ( ) ; unit . cancel ( ) ; } else if ( op === '/' ) { unit . numerator = unit . numerator . concat ( other . unit . denominator ) . sort ( ) ; unit . denominator = unit . denominator . concat ( other . unit . numerator ) . sort ( ) ; unit . cancel ( ) ; } return new ( tree . Dimension ) ( value , unit ) ; }
In an operation between two Dimensions, we default to the first Dimension's unit, so `1px + 2` will yield `3px`.
In an operation between two Dimensions we default to the first Dimension s unit so 1px + 2 will yield 3px .