From 2ed9416e198ed93ac47ebdca33ac854f35789744 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 25 Jul 2015 02:16:31 +0100 Subject: [PATCH] check whether the last child is the same node as the one we're removing comments from - fixes #2072, fixes #2068 --- packages/babylon/src/comments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babylon/src/comments.js b/packages/babylon/src/comments.js index dd6edafa48..56cdb5d0f4 100644 --- a/packages/babylon/src/comments.js +++ b/packages/babylon/src/comments.js @@ -73,7 +73,7 @@ pp.processComment = function (node) { } if (lastChild) { - if (lastChild.leadingComments && last(lastChild.leadingComments).end <= node.start) { + if (lastChild !== node && lastChild.leadingComments && last(lastChild.leadingComments).end <= node.start) { node.leadingComments = lastChild.leadingComments; lastChild.leadingComments = null; }