Skip to content

Commit 94b2cb4

Browse files
authored
refactor: Modify this pointer so that it is not empty. (#3719)
* refactor: Modify this pointer so that it is not empty. * fix: Supplementary test cases.
1 parent c155d14 commit 94b2cb4

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ const minMax = function (isMin, args) {
5151
if (order.length == 1) {
5252
return order[0];
5353
}
54-
args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
54+
args = order.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
5555
return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);
5656
};
5757

5858
export default {
5959
min: function(...args) {
6060
try {
61-
return minMax(true, args);
61+
return minMax.call(this, true, args);
6262
} catch (e) {}
6363
},
6464
max: function(...args) {
6565
try {
66-
return minMax(false, args);
66+
return minMax.call(this, false, args);
6767
} catch (e) {}
6868
},
6969
convert: function (val, unit) {

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

+2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@
109109
min: 5;
110110
min: 1pt;
111111
min: 3mm;
112+
min: min(1, 4ex, 2pt);
112113
max: 3;
113114
max: 5em;
115+
max: max(5m, 3em);
114116
max-native: max(10vw, 100px);
115117
percentage: 20%;
116118
color-quoted-digit: #dda0dd;

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@
116116
min: min(6, 5);
117117
min: min(1pt, 3pt);
118118
min: min(1cm, 3mm);
119+
min: min(6em, 5, 4ex, 3, 2pt, 1);
119120
max: max(1, 3);
120121
max: max(3em, 1em, 2em, 5em);
122+
max: max(1px, 2, 3em, 4, 5m, 6);
121123
max-native: max(10vw, 100px);
122124
percentage: percentage((10px / 50));
123125
color-quoted-digit: color("#dda0dd");
@@ -135,11 +137,11 @@
135137

136138
fade-out: fadeout(red, 5%); // support fadeOut and fadeout
137139
fade-in: fadein(fadeout(red, 10%), 5%);
138-
fade-out-relative: fadeout(red, 5%,relative);
140+
fade-out-relative: fadeout(red, 5%,relative);
139141
fade-in-relative: fadein(fadeout(red, 10%, relative), 5%, relative);
140-
fade-out2: fadeout(fadeout(red, 50%), 50%);
142+
fade-out2: fadeout(fadeout(red, 50%), 50%);
141143
fade-out2-relative: fadeout(fadeout(red, 50%, relative), 50%, relative);
142-
144+
143145
hsv: hsv(5, 50%, 30%);
144146
hsva: hsva(3, 50%, 30%, 0.2);
145147

@@ -269,7 +271,7 @@ html {
269271
// see: https://github.com/less/less.js/issues/3371
270272
@some: foo;
271273
l: if((iscolor(@some)), darken(@some, 10%), black);
272-
274+
273275

274276
if((false), {g: 7}); /* results in void */
275277

0 commit comments

Comments
 (0)