Skip to content

Commit 145d95e

Browse files
authored
fix(issue:4264) strip line comment from expression (#4293)
* Fix for issue #4264. Strip line comments from expressions to avoid invalid CSS output.
1 parent 304c310 commit 145d95e

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
@@ -2418,7 +2418,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
24182418

24192419
do {
24202420
e = this.comment();
2421-
if (e) {
2421+
if (e && !e.isLineComment) {
24222422
entities.push(e);
24232423
continue;
24242424
}

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

+15
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,18 @@
8080
.radio_checked {
8181
border-color: #fff;
8282
}
83+
div#apple {
84+
color: blue;
85+
}
86+
div#banana {
87+
color: blue;
88+
}
89+
div#cherry {
90+
color: blue;
91+
}
92+
div#carrot {
93+
color: blue;
94+
}
95+
div#potato {
96+
color: blue;
97+
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,19 @@
143143
.@{radio-cls-checked} {
144144
border-color: #fff;
145145
}
146+
147+
@items:
148+
// Fruit
149+
apple,
150+
banana,
151+
cherry,
152+
// Vegetables
153+
carrot,
154+
potato,
155+
;
156+
157+
each(@items, {
158+
div#@{value} {
159+
color: blue;
160+
}
161+
})

0 commit comments

Comments
 (0)