fix: assign comment to ObjectProperty only when inside an ObjectExpression (#10292)

Fixes #10230
This commit is contained in:
Huáng Jùnliàng
2019-08-13 14:49:16 -04:00
committed by Brian Ng
parent 22df2ae244
commit 75090f10e5
3 changed files with 247 additions and 1 deletions

View File

@@ -91,7 +91,7 @@ export default class CommentsParser extends BaseParser {
const lastComment = last(this.state.leadingComments);
if (firstChild.type === "ObjectProperty") {
if (lastComment.start >= node.start) {
if (lastComment.start >= node.start && lastComment.end <= node.end) {
if (this.state.commentPreviousNode) {
for (j = 0; j < this.state.leadingComments.length; j++) {
if (