From a141d0ac938edcbab63fc9b75b43f441f5ff2f68 Mon Sep 17 00:00:00 2001 From: Daniel Puckowski Date: Wed, 27 Nov 2024 17:51:40 -0500 Subject: [PATCH] fix(issue:4258) variable interpolation after math * Fixes variable interpolation issue after previous variable addition. --- 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 59aa2eef4..fd560512b 100644 --- a/packages/less/src/less/parser/parser.js +++ b/packages/less/src/less/parser/parser.js @@ -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); } diff --git a/packages/test-data/css/_main/variables.css b/packages/test-data/css/_main/variables.css index fa03b1eb7..b1ac96569 100644 --- a/packages/test-data/css/_main/variables.css +++ b/packages/test-data/css/_main/variables.css @@ -69,3 +69,6 @@ mul-px-2: 140px; mul-px-3: 140px; } +.radio_checked { + border-color: #fff; +} diff --git a/packages/test-data/less/_main/variables.less b/packages/test-data/less/_main/variables.less index ae8c9be45..6ef921826 100644 --- a/packages/test-data/less/_main/variables.less +++ b/packages/test-data/less/_main/variables.less @@ -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; +}