From dca16509c2e96ffabe8d5ff1645ed0c3d8088fe5 Mon Sep 17 00:00:00 2001 From: Luke Page Date: Wed, 6 Mar 2013 10:07:43 +0000 Subject: [PATCH] fix regression: mixin guards compare units correctly --- lib/less/tree/dimension.js | 2 +- test/css/mixins-guards.css | 5 +++++ test/less/mixins-guards.less | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/less/tree/dimension.js b/lib/less/tree/dimension.js index b3a19782..0b10f87f 100644 --- a/lib/less/tree/dimension.js +++ b/lib/less/tree/dimension.js @@ -93,7 +93,7 @@ tree.Dimension.prototype = { } else if (bValue < aValue) { return 1; } else { - if (!b.unit.isEmpty() && a.unit.compare(b) !== 0) { + if (!b.unit.isEmpty() && a.unit.compare(b.unit) !== 0) { return -1; } return 0; diff --git a/test/css/mixins-guards.css b/test/css/mixins-guards.css index f899a8e3..847aef12 100644 --- a/test/css/mixins-guards.css +++ b/test/css/mixins-guards.css @@ -69,3 +69,8 @@ content: is not theme2; content: is theme1 no quotes; } +#tryNumberPx { + catch: all; + declare: 4; + declare: 4px; +} diff --git a/test/less/mixins-guards.less b/test/less/mixins-guards.less index 4414e326..4e35401b 100644 --- a/test/less/mixins-guards.less +++ b/test/less/mixins-guards.less @@ -121,4 +121,17 @@ .stringguard("theme1"); .stringguard("theme2"); .stringguard(theme1); +} + +.mixin(...) { + catch:all; +} +.mixin(@var) when (@var=4) { + declare: 4; +} +.mixin(@var) when (@var=4px) { + declare: 4px; +} +#tryNumberPx { + .mixin(4px); } \ No newline at end of file