Skip to content

Commit

Permalink
fix(issue:4258) variable interpolation after math
Browse files Browse the repository at this point in the history
* Fixes variable interpolation issue after previous variable addition.
  • Loading branch information
puckowski committed Nov 27, 2024
1 parent 773e157 commit a141d0a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/less/src/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,9 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
}
// Treat like quoted values, but replace vars like unquoted expressions
const quote = new tree.Quoted('\'', item, true, index, fileInfo);
quote.variableRegex = /@([\w-]+)/g;
if (!item.startsWith('@{')) {
quote.variableRegex = /@([\w-]+)/g;
}
quote.propRegex = /\$([\w-]+)/g;
result.push(quote);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/test-data/css/_main/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@
mul-px-2: 140px;
mul-px-3: 140px;
}
.radio_checked {
border-color: #fff;
}
11 changes: 11 additions & 0 deletions packages/test-data/less/_main/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,14 @@
mul-px-3: ((@px * 1) * @cm);
}
}

@a1: 1px;
@b2: 2px;
@c3: @a1 + @b2;

@radio-cls: radio;
@radio-cls-checked: @{radio-cls}_checked;

.@{radio-cls-checked} {
border-color: #fff;
}

0 comments on commit a141d0a

Please sign in to comment.