Skip to content

Commit

Permalink
Fix #3616 IfStatement requires double parentheses when dividing (#3626)
Browse files Browse the repository at this point in the history
* fix: fix the special parens case
* fix the issue number
  • Loading branch information
iChenLei committed Jun 12, 2021
1 parent b37922c commit c518180
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/less/src/less/functions/function-caller.js
Expand Up @@ -32,6 +32,10 @@ class functionCaller {
if (item.type === 'Expression') {
const subNodes = item.value.filter(commentFilter);
if (subNodes.length === 1) {
// https://github.com/less/less.js/issues/3616
if (item.parens && subNodes[0].op === '/') {
return item;
}
return subNodes[0];
} else {
return new Expression(subNodes);
Expand Down
5 changes: 5 additions & 0 deletions packages/test-data/css/math/parens-division/parens.css
@@ -1,3 +1,8 @@
.parens-issues-3616 {
bar: 888 / 444;
bar2: 2;
bar3: 2;
}
.parens {
border: 2px solid black;
margin: 1px 3px 16 3;
Expand Down
5 changes: 5 additions & 0 deletions packages/test-data/css/math/strict/parens.css
@@ -1,3 +1,8 @@
.parens-issues-3616 {
bar: 888 / 444;
bar2: 2;
bar3: 2;
}
.parens {
border: 2px solid black;
margin: 1px 3px 16 3;
Expand Down
6 changes: 6 additions & 0 deletions packages/test-data/less/math/parens-division/parens.less
@@ -1,3 +1,9 @@
.parens-issues-3616 {
bar: if(false, 666, 888 / 444);
bar2: if(false, 666, (666 / 333));
bar3: if(false, 666, ((444 / 222)));
}

.parens {
@var: 1px;
border: (@var * 2) solid black;
Expand Down
6 changes: 6 additions & 0 deletions packages/test-data/less/math/strict/parens.less
@@ -1,3 +1,9 @@
.parens-issues-3616 {
bar: if(false, 666, 888 / 444);
bar2: if(false, 666, (666 / 333));
bar3: if(false, 666, ((444 / 222)));
}

.parens {
@var: 1px;
border: (@var * 2) solid black;
Expand Down

0 comments on commit c518180

Please sign in to comment.