From 9f97c8e8620f302045a05bb5204cd92df9cd824c Mon Sep 17 00:00:00 2001 From: Daniel Puckowski Date: Thu, 28 Nov 2024 05:59:38 -0500 Subject: [PATCH] fix(issue:4264) strip line comment from expression * Fix for issue #4264. Strip line comments from expressions to avoid invalid CSS output. --- packages/less/src/less/parser/parser.js | 2 +- packages/test-data/css/_main/variables.css | 15 +++++++++++++++ packages/test-data/less/_main/variables.less | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/less/src/less/parser/parser.js b/packages/less/src/less/parser/parser.js index 139e954af..97840fa9d 100644 --- a/packages/less/src/less/parser/parser.js +++ b/packages/less/src/less/parser/parser.js @@ -2416,7 +2416,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) { do { e = this.comment(); - if (e) { + if (e && !e.isLineComment) { entities.push(e); continue; } diff --git a/packages/test-data/css/_main/variables.css b/packages/test-data/css/_main/variables.css index ffa374106..73e271403 100644 --- a/packages/test-data/css/_main/variables.css +++ b/packages/test-data/css/_main/variables.css @@ -77,3 +77,18 @@ --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; } +div#apple { + color: blue; +} +div#banana { + color: blue; +} +div#cherry { + color: blue; +} +div#carrot { + color: blue; +} +div#potato { + color: blue; +} diff --git a/packages/test-data/less/_main/variables.less b/packages/test-data/less/_main/variables.less index 4f3a7a324..cb51b69ef 100644 --- a/packages/test-data/less/_main/variables.less +++ b/packages/test-data/less/_main/variables.less @@ -132,3 +132,19 @@ --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; } + +@items: +// Fruit + apple, + banana, + cherry, +// Vegetables + carrot, + potato, +; + +each(@items, { + div#@{value} { + color: blue; + } +})