Skip to content

Commit

Permalink
Fix issue with comments being duplicated when replacing the root node
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBaryoPX committed Oct 16, 2024
1 parent 8f6310b commit f3305ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/arborist.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ const Arborist = class {
const leadingComments = rootNode.leadingComments || [];
const trailingComments = rootNode.trailingComments || [];
rootNode = rootNodeReplacement[1];
if (leadingComments.length) rootNode.leadingComments = (rootNode.leadingComments || []).concat(leadingComments);
if (trailingComments.length) rootNode.trailingComments = (rootNode.trailingComments || []).concat(trailingComments);
if (leadingComments.length && rootNode.leadingComments !== leadingComments) rootNode.leadingComments = (rootNode.leadingComments || []).concat(leadingComments);
if (trailingComments.length && rootNode.trailingComments !== trailingComments) rootNode.trailingComments = (rootNode.trailingComments || []).concat(trailingComments);
} else {
for (const targetNodeId of this.markedForDeletion) {
try {
Expand Down

0 comments on commit f3305ff

Please sign in to comment.