Skip to content

Commit

Permalink
fix(issue:4258) variable interpolation after math (less#4292)
Browse files Browse the repository at this point in the history
* fix(issue:4258) variable interpolation after math

* Fixes variable interpolation issue after previous variable addition.

* chore: fix rebase issue

* Fix rebase issue for fix for issue less#4258.
  • Loading branch information
puckowski authored Dec 8, 2024
1 parent 509a007 commit 304c310
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 @@ -1731,7 +1731,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 @@ -77,3 +77,6 @@
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
}
.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 @@ -132,3 +132,14 @@
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
}

@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 304c310

Please sign in to comment.