Skip to content

Commit

Permalink
refactor: Modify this pointer so that it is not empty. (#3719)
Browse files Browse the repository at this point in the history
* refactor: Modify this pointer so that it is not empty.

* fix: Supplementary test cases.
  • Loading branch information
lumburr authored Aug 20, 2022
1 parent c155d14 commit 94b2cb4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/less/src/less/functions/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ const minMax = function (isMin, args) {
if (order.length == 1) {
return order[0];
}
args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
args = order.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);
};

export default {
min: function(...args) {
try {
return minMax(true, args);
return minMax.call(this, true, args);
} catch (e) {}
},
max: function(...args) {
try {
return minMax(false, args);
return minMax.call(this, false, args);
} catch (e) {}
},
convert: function (val, unit) {
Expand Down
2 changes: 2 additions & 0 deletions packages/test-data/css/_main/functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@
min: 5;
min: 1pt;
min: 3mm;
min: min(1, 4ex, 2pt);
max: 3;
max: 5em;
max: max(5m, 3em);
max-native: max(10vw, 100px);
percentage: 20%;
color-quoted-digit: #dda0dd;
Expand Down
10 changes: 6 additions & 4 deletions packages/test-data/less/_main/functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@
min: min(6, 5);
min: min(1pt, 3pt);
min: min(1cm, 3mm);
min: min(6em, 5, 4ex, 3, 2pt, 1);
max: max(1, 3);
max: max(3em, 1em, 2em, 5em);
max: max(1px, 2, 3em, 4, 5m, 6);
max-native: max(10vw, 100px);
percentage: percentage((10px / 50));
color-quoted-digit: color("#dda0dd");
Expand All @@ -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);

Expand Down Expand Up @@ -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 */

Expand Down

0 comments on commit 94b2cb4

Please sign in to comment.