From f10abf431ea78951be168087bfd1384aa8d8e3c6 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 | 5 +++++ packages/test-data/less/_main/variables.less | 11 +++++++++++ 3 files changed, 19 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..9375358d2 100644 --- a/packages/test-data/css/_main/variables.css +++ b/packages/test-data/css/_main/variables.css @@ -69,6 +69,7 @@ mul-px-2: 140px; mul-px-3: 140px; } +<<<<<<< HEAD *, ::before, ::after { @@ -76,4 +77,8 @@ --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; +======= +.radio_checked { + border-color: #fff; +>>>>>>> 9434f18b (fix(issue:4258) variable interpolation after math) } 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; +}