From 304c3106d82690531ce8f1d6a07ea268e98e54a1 Mon Sep 17 00:00:00 2001 From: Daniel Puckowski Date: Sun, 8 Dec 2024 07:51:12 -0500 Subject: [PATCH] fix(issue:4258) variable interpolation after math (#4292) * 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 #4258. --- packages/less/src/less/parser/parser.js | 4 +++- packages/test-data/css/_main/variables.css | 3 +++ packages/test-data/less/_main/variables.less | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/less/src/less/parser/parser.js b/packages/less/src/less/parser/parser.js index 139e954af..b87b4d762 100644 --- a/packages/less/src/less/parser/parser.js +++ b/packages/less/src/less/parser/parser.js @@ -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); } diff --git a/packages/test-data/css/_main/variables.css b/packages/test-data/css/_main/variables.css index ffa374106..3fac8c7f4 100644 --- a/packages/test-data/css/_main/variables.css +++ b/packages/test-data/css/_main/variables.css @@ -77,3 +77,6 @@ --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; } +.radio_checked { + border-color: #fff; +} diff --git a/packages/test-data/less/_main/variables.less b/packages/test-data/less/_main/variables.less index 4f3a7a324..c35ccc5b0 100644 --- a/packages/test-data/less/_main/variables.less +++ b/packages/test-data/less/_main/variables.less @@ -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; +}