Skip to content

Commit

Permalink
fix: Output correct css when using css function in max(). (#4266)
Browse files Browse the repository at this point in the history
* 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 <flyfish.zy@foxmail.com>
  • Loading branch information
SoonIter and lumburr authored Nov 21, 2024
1 parent 09b8f5c commit b09ad0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/less/src/less/functions/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ 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;
} else {
throw { type: 'Argument', message: 'incompatible types' };
}
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();
Expand Down
4 changes: 4 additions & 0 deletions packages/test-data/css/_main/functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@
min: 1pt;
min: 3mm;
min: min(1, 4ex, 2pt);
min: min(calc(1 + 1), 1);
min: min(var(--width), 802px);
max: 3;
max: 5em;
max: max(5m, 3em);
max: min(var(--body-max-width), calc(100vw - 20px));
max: max(1, calc(1 + 1));
max-native: max(10vw, 100px);
percentage: 20%;
color-quoted-digit: #dda0dd;
Expand Down
4 changes: 4 additions & 0 deletions packages/test-data/less/_main/functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@
min: min(1pt, 3pt);
min: min(1cm, 3mm);
min: min(6em, 5, 4ex, 3, 2pt, 1);
min: min(calc(1 + 1), 1);
min: min(~'var(--width), 802px');
max: max(1, 3);
max: max(3em, 1em, 2em, 5em);
max: max(1px, 2, 3em, 4, 5m, 6);
max: min(var(--body-max-width), calc(100vw - 20px));
max: max(1, calc(1 + 1));
max-native: max(10vw, 100px);
percentage: percentage((10px / 50));
color-quoted-digit: color("#dda0dd");
Expand Down

0 comments on commit b09ad0f

Please sign in to comment.