Given a loud comment with new lines:
@mixin x {
margin: 10px;
}
/*
* loud
* comment
*
*/
.a {
@include x;
}
If I wanted to insert a new comment, e.g.:
const node = postcss.comment({
text: 'New Comment',
raws: {'inline': true, 'right': '', 'left': ' ', before:''},
});
console.log(node);
The log has the correct raws:
{"raws":{"inline":true,"right":"","left":" ","before":""},"text":"New Comment","type":"comment","inputs":[]}
But after insertion, the raws.before property is cloned from the original comment:
comment.before(node);
const previousComment = comment.prev() as postcss.Comment;
console.log(previousComment)
So the result is the following:
{
"raws": {
"inline": true,
"right": "",
"left": " ",
"before": "\n\n" // Should be ""
},
"text": "New comment",
"type": "comment",
"inputs": []
}
Given a loud comment with new lines:
If I wanted to insert a new comment, e.g.:
The log has the correct raws:
{"raws":{"inline":true,"right":"","left":" ","before":""},"text":"New Comment","type":"comment","inputs":[]}But after insertion, the
raws.beforeproperty is cloned from the original comment:So the result is the following: