Skip to content

Commit 6cb838a

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 773e157 commit 6cb838a

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

23932393
do {
23942394
e = this.comment();
2395-
if (e) {
2395+
if (e && !e.isLineComment) {
23962396
entities.push(e);
23972397
continue;
23982398
}

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

+15
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,18 @@
6969
mul-px-2: 140px;
7070
mul-px-3: 140px;
7171
}
72+
div#apple {
73+
color: blue;
74+
}
75+
div#banana {
76+
color: blue;
77+
}
78+
div#cherry {
79+
color: blue;
80+
}
81+
div#carrot {
82+
color: blue;
83+
}
84+
div#potato {
85+
color: blue;
86+
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,19 @@
125125
mul-px-3: ((@px * 1) * @cm);
126126
}
127127
}
128+
129+
@items:
130+
// Fruit
131+
apple,
132+
banana,
133+
cherry,
134+
// Vegetables
135+
carrot,
136+
potato,
137+
;
138+
139+
each(@items, {
140+
div#@{value} {
141+
color: blue;
142+
}
143+
})

0 commit comments

Comments
 (0)