Fix unit comparing after merge

This commit is contained in:
Luke Page
2012-11-27 09:55:08 +00:00
parent c1efcf4e57
commit 4633f7cc4c

View File

@@ -56,14 +56,15 @@ tree.Dimension.prototype = {
compare: function (other) {
if (other instanceof tree.Dimension) {
var a = this.unify().value, b = other.unify().value;
var a = this.unify(), b = other.unify(),
aValue = a.value, bValue = b.value;
if (b > a) {
if (bValue > aValue) {
return -1;
} else if (b < a) {
} else if (bValue < aValue) {
return 1;
} else {
if (other.unit && this.unit !== other.unit) {
if (!b.unit.isEmpty() && a.unit.compare(b) !== 0) {
return -1;
}
return 0;
@@ -141,6 +142,10 @@ tree.Unit.prototype = {
}
return css;
},
compare: function (other) {
return this.is(other.toCSS()) ? 0 : -1;
},
is: function (unitString) {
return this.toCSS() === unitString;