From b85db8f6979b80d8cf6105170995e2f02756b8f4 Mon Sep 17 00:00:00 2001 From: lumburr Date: Wed, 30 Mar 2022 15:05:42 +0800 Subject: [PATCH 1/2] fix: Output correct css when using css function in max(). --- packages/less/src/less/functions/number.js | 2 +- packages/test-data/css/_main/functions.css | 2 ++ packages/test-data/less/_main/functions.less | 10 ++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/less/src/less/functions/number.js b/packages/less/src/less/functions/number.js index f01689472..9c086f420 100644 --- a/packages/less/src/less/functions/number.js +++ b/packages/less/src/less/functions/number.js @@ -26,8 +26,8 @@ const minMax = function (isMin, args) { if (!(current instanceof Dimension)) { if (Array.isArray(args[i].value)) { Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value)); + continue; } - continue; } currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify(); unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString(); diff --git a/packages/test-data/css/_main/functions.css b/packages/test-data/css/_main/functions.css index 56ab9ea02..29d94bb7f 100644 --- a/packages/test-data/css/_main/functions.css +++ b/packages/test-data/css/_main/functions.css @@ -109,8 +109,10 @@ min: 5; min: 1pt; min: 3mm; + min: min(calc(1 + 1), 1); max: 3; max: 5em; + max: max(1, calc(1 + 1)); max-native: max(10vw, 100px); percentage: 20%; color-quoted-digit: #dda0dd; diff --git a/packages/test-data/less/_main/functions.less b/packages/test-data/less/_main/functions.less index bad7b5cdb..c7ea867aa 100644 --- a/packages/test-data/less/_main/functions.less +++ b/packages/test-data/less/_main/functions.less @@ -116,8 +116,10 @@ min: min(6, 5); min: min(1pt, 3pt); min: min(1cm, 3mm); + min: min(calc(1 + 1), 1); max: max(1, 3); max: max(3em, 1em, 2em, 5em); + max: max(1, calc(1 + 1)); max-native: max(10vw, 100px); percentage: percentage((10px / 50)); color-quoted-digit: color("#dda0dd"); @@ -135,11 +137,11 @@ fade-out: fadeout(red, 5%); // support fadeOut and fadeout fade-in: fadein(fadeout(red, 10%), 5%); - fade-out-relative: fadeout(red, 5%,relative); + fade-out-relative: fadeout(red, 5%,relative); fade-in-relative: fadein(fadeout(red, 10%, relative), 5%, relative); - fade-out2: fadeout(fadeout(red, 50%), 50%); + fade-out2: fadeout(fadeout(red, 50%), 50%); fade-out2-relative: fadeout(fadeout(red, 50%, relative), 50%, relative); - + hsv: hsv(5, 50%, 30%); hsva: hsva(3, 50%, 30%, 0.2); @@ -269,7 +271,7 @@ html { // see: https://github.com/less/less.js/issues/3371 @some: foo; l: if((iscolor(@some)), darken(@some, 10%), black); - + if((false), {g: 7}); /* results in void */ From e69007ab5a9417b277125b66af536465f12976b8 Mon Sep 17 00:00:00 2001 From: lumburr Date: Sun, 24 Apr 2022 14:54:12 +0800 Subject: [PATCH 2/2] fix: If a non-Dimension value is handled in minMax(), then throw Atgument exception. --- packages/less/src/less/functions/number.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/less/src/less/functions/number.js b/packages/less/src/less/functions/number.js index 9c086f420..7e3135f28 100644 --- a/packages/less/src/less/functions/number.js +++ b/packages/less/src/less/functions/number.js @@ -27,6 +27,8 @@ const minMax = function (isMin, args) { if (Array.isArray(args[i].value)) { Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value)); continue; + } else { + throw { type: 'Argument', message: 'incompatible types' }; } } currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();