[Pkg-javascript-commits] [less.js] 12/88: max/min Bugfix

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:22:21 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v1.7.0
in repository less.js.

commit 7bbf7cef971582fc2dc09247e209df62234b6daa
Author: deviprsd21 <deviprsd21 at gmail.com>
Date:   Wed Jan 15 17:46:17 2014 +0530

    max/min Bugfix
    
    max(0, 1cm)// 0 ... 0 assumed unit "m". on comparison 0.01m was less than 0
---
 lib/less/functions.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/less/functions.js b/lib/less/functions.js
index 74c15e6..7df372e 100644
--- a/lib/less/functions.js
+++ b/lib/less/functions.js
@@ -266,10 +266,10 @@ tree.functions = {
         switch(args.length) {
             case 0: throw { type: "Argument", message: "one or more arguments required" };
         }
-        var i, j, current, currentUnified, referenceUnified, unit, unitStatic,
+        var i, j, current, currentUnified, referenceUnified, unit, unitStatic, unitClone,
             order  = [], // elems only contains original argument values.
             values = {}; // key is the unit.toString() for unified tree.Dimension values,
-                         // value is the index into the order array
+                         // value is the index into the order array.
         for (i = 0; i < args.length; i++) {
             current = args[i];
             if (!(current instanceof tree.Dimension)) {
@@ -278,11 +278,11 @@ tree.functions = {
                 }
                 continue;
             }
-            currentUnified = current.unify();
+            currentUnified = current.unit.toString() === "" && unitClone !== undefined ? new(tree.Dimension)(current.value, unitClone).unify() : current.unify();
             unit = currentUnified.unit.toString() === "" && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();			
-            unitStatic = unit !== "" && unitStatic === undefined ? unit : unitStatic;
-            values[unit] = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit];
-            j = values[unit];
+            unitStatic = unit !== "" && unitStatic === undefined || unit !== "" && order[0].unify().unit.toString() === "" ? unit : unitStatic;
+            unitClone = unit !== "" && unitClone === undefined ? current.unit.toString() : unitClone;
+            j = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit];
             if (j === undefined) {
                 if(unitStatic !== undefined && unit !== unitStatic) {
                     throw{ type: "Argument", message: "incompatible types" };
@@ -291,7 +291,7 @@ tree.functions = {
                 order.push(current);
                 continue;
             }
-            referenceUnified = order[j].unify();
+            referenceUnified = order[j].unit.toString() === "" && unitClone !== undefined ? new(tree.Dimension)(order[j].value, unitClone).unify() : order[j].unify();
             if ( isMin && currentUnified.value < referenceUnified.value ||
                 !isMin && currentUnified.value > referenceUnified.value) {
                 order[j] = current;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list