Skip to content

Commit b09ad0f

Browse files
SoonIterlumburr
andauthored
fix: Output correct css when using css function in max(). (#4266)
* fix: Output correct css when using css function in max(). * fix: If a non-Dimension value is handled in minMax(), then throw Atgument exception. * chore: add more test cases * chore: rebase the lock --------- Co-authored-by: lumburr <[email protected]>
1 parent 09b8f5c commit b09ad0f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

packages/less/src/less/functions/number.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ const minMax = function (isMin, args) {
2626
if (!(current instanceof Dimension)) {
2727
if (Array.isArray(args[i].value)) {
2828
Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));
29+
continue;
30+
} else {
31+
throw { type: 'Argument', message: 'incompatible types' };
2932
}
30-
continue;
3133
}
3234
currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();
3335
unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();

packages/test-data/css/_main/functions.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,13 @@
110110
min: 1pt;
111111
min: 3mm;
112112
min: min(1, 4ex, 2pt);
113+
min: min(calc(1 + 1), 1);
114+
min: min(var(--width), 802px);
113115
max: 3;
114116
max: 5em;
115117
max: max(5m, 3em);
118+
max: min(var(--body-max-width), calc(100vw - 20px));
119+
max: max(1, calc(1 + 1));
116120
max-native: max(10vw, 100px);
117121
percentage: 20%;
118122
color-quoted-digit: #dda0dd;

packages/test-data/less/_main/functions.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,13 @@
117117
min: min(1pt, 3pt);
118118
min: min(1cm, 3mm);
119119
min: min(6em, 5, 4ex, 3, 2pt, 1);
120+
min: min(calc(1 + 1), 1);
121+
min: min(~'var(--width), 802px');
120122
max: max(1, 3);
121123
max: max(3em, 1em, 2em, 5em);
122124
max: max(1px, 2, 3em, 4, 5m, 6);
125+
max: min(var(--body-max-width), calc(100vw - 20px));
126+
max: max(1, calc(1 + 1));
123127
max-native: max(10vw, 100px);
124128
percentage: percentage((10px / 50));
125129
color-quoted-digit: color("#dda0dd");

0 commit comments

Comments
 (0)