Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3616 IfStatement requires double parentheses when dividing #3626

Merged
merged 2 commits into from
Jun 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/less/src/less/functions/function-caller.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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