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 less#4264. Strip line comments from expressions to avoid
  invalid CSS output.
  • Loading branch information
puckowski committed Nov 28, 2024
1 parent 773e157 commit 6cb838a
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 @@ -2392,7 +2392,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 @@ -69,3 +69,18 @@
mul-px-2: 140px;
mul-px-3: 140px;
}
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 @@ -125,3 +125,19 @@
mul-px-3: ((@px * 1) * @cm);
}
}

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

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

0 comments on commit 6cb838a

Please sign in to comment.