Skip to content

Commit c518180

Browse files
authored
Fix #3616 IfStatement requires double parentheses when dividing (#3626)
* fix: fix the special parens case * fix the issue number
1 parent b37922c commit c518180

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

packages/less/src/less/functions/function-caller.js

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class functionCaller {
3232
if (item.type === 'Expression') {
3333
const subNodes = item.value.filter(commentFilter);
3434
if (subNodes.length === 1) {
35+
// https://github.com/less/less.js/issues/3616
36+
if (item.parens && subNodes[0].op === '/') {
37+
return item;
38+
}
3539
return subNodes[0];
3640
} else {
3741
return new Expression(subNodes);

packages/test-data/css/math/parens-division/parens.css

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.parens-issues-3616 {
2+
bar: 888 / 444;
3+
bar2: 2;
4+
bar3: 2;
5+
}
16
.parens {
27
border: 2px solid black;
38
margin: 1px 3px 16 3;

packages/test-data/css/math/strict/parens.css

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.parens-issues-3616 {
2+
bar: 888 / 444;
3+
bar2: 2;
4+
bar3: 2;
5+
}
16
.parens {
27
border: 2px solid black;
38
margin: 1px 3px 16 3;

packages/test-data/less/math/parens-division/parens.less

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
.parens-issues-3616 {
2+
bar: if(false, 666, 888 / 444);
3+
bar2: if(false, 666, (666 / 333));
4+
bar3: if(false, 666, ((444 / 222)));
5+
}
6+
17
.parens {
28
@var: 1px;
39
border: (@var * 2) solid black;

packages/test-data/less/math/strict/parens.less

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
.parens-issues-3616 {
2+
bar: if(false, 666, 888 / 444);
3+
bar2: if(false, 666, (666 / 333));
4+
bar3: if(false, 666, ((444 / 222)));
5+
}
6+
17
.parens {
28
@var: 1px;
39
border: (@var * 2) solid black;

0 commit comments

Comments
 (0)