Skip to content

Commit 9f97c8e

Browse files
committed
fix(issue:4264) strip line comment from expression
* Fix for issue less#4264. Strip line comments from expressions to avoid invalid CSS output.
1 parent 509a007 commit 9f97c8e

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

packages/less/src/less/parser/parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
24162416

24172417
do {
24182418
e = this.comment();
2419-
if (e) {
2419+
if (e && !e.isLineComment) {
24202420
entities.push(e);
24212421
continue;
24222422
}

packages/test-data/css/_main/variables.css

+15
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,18 @@
7777
--tw-pinch-zoom: ;
7878
--tw-scroll-snap-strictness: proximity;
7979
}
80+
div#apple {
81+
color: blue;
82+
}
83+
div#banana {
84+
color: blue;
85+
}
86+
div#cherry {
87+
color: blue;
88+
}
89+
div#carrot {
90+
color: blue;
91+
}
92+
div#potato {
93+
color: blue;
94+
}

packages/test-data/less/_main/variables.less

+16
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,19 @@
132132
--tw-pinch-zoom: ;
133133
--tw-scroll-snap-strictness: proximity;
134134
}
135+
136+
@items:
137+
// Fruit
138+
apple,
139+
banana,
140+
cherry,
141+
// Vegetables
142+
carrot,
143+
potato,
144+
;
145+
146+
each(@items, {
147+
div#@{value} {
148+
color: blue;
149+
}
150+
})

0 commit comments

Comments
 (0)