lib/less/js/lib/less/tree/dimension.js in less-2.5.1 vs lib/less/js/lib/less/tree/dimension.js in less-2.6.0
- old
+ new
@@ -87,30 +87,40 @@
return new(tree.Dimension)(value, unit);
},
compare: function (other) {
if (other instanceof tree.Dimension) {
- var a = this.unify(), b = other.unify(),
- aValue = a.value, bValue = b.value;
+ var a, b,
+ aValue, bValue;
+
+ if (this.unit.isEmpty() || other.unit.isEmpty()) {
+ a = this;
+ b = other;
+ } else {
+ a = this.unify();
+ b = other.unify();
+ if (a.unit.compare(b.unit) !== 0) {
+ return -1;
+ }
+ }
+ aValue = a.value;
+ bValue = b.value;
if (bValue > aValue) {
return -1;
} else if (bValue < aValue) {
return 1;
} else {
- if (!b.unit.isEmpty() && a.unit.compare(b.unit) !== 0) {
- return -1;
- }
return 0;
}
} else {
return -1;
}
},
unify: function () {
- return this.convertTo({ length: 'm', duration: 's', angle: 'rad' });
+ return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });
},
convertTo: function (conversions) {
var value = this.value, unit = this.unit.clone(),
i, groupName, group, targetUnit, derivedConversions = {}, applyUnit;
@@ -159,9 +169,10 @@
length: {
'm': 1,
'cm': 0.01,
'mm': 0.001,
'in': 0.0254,
+ 'px': 0.0254 / 96,
'pt': 0.0254 / 72,
'pc': 0.0254 / 72 * 12
},
duration: {
's': 1,