Skip to content

Commit

Permalink
fix(issue:4264) strip line comment from expression
Browse files Browse the repository at this point in the history
* Fix for issue #4264. Strip line comments from expressions to avoid
  invalid CSS output.
  • Loading branch information
puckowski committed Dec 8, 2024
1 parent 304c310 commit b946376
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/less/src/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {

do {
e = this.comment();
if (e) {
if (e && !e.isLineComment) {
entities.push(e);
continue;
}
Expand Down
15 changes: 15 additions & 0 deletions packages/test-data/css/_main/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,18 @@
.radio_checked {
border-color: #fff;
}
div#apple {
color: blue;
}
div#banana {
color: blue;
}
div#cherry {
color: blue;
}
div#carrot {
color: blue;
}
div#potato {
color: blue;
}
16 changes: 16 additions & 0 deletions packages/test-data/less/_main/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,19 @@
.@{radio-cls-checked} {
border-color: #fff;
}

@items:
// Fruit
apple,
banana,
cherry,
// Vegetables
carrot,
potato,
;

each(@items, {
div#@{value} {
color: blue;
}
})

0 comments on commit b946376

Please sign in to comment.