Skip to content

Commit 7f0c84c

Browse files
committed
fix: filter out jsx comments in getChildren
fixes #46
1 parent 58df392 commit 7f0c84c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: packages/babel-plugin-transform-vue-jsx/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const getChildren = (t, paths) =>
8282
/* istanbul ignore next */
8383
throw new Error(`getChildren: ${path.type} is not supported`)
8484
})
85-
.filter(el => el !== null)
85+
.filter(el => el !== null && !t.isJSXEmptyExpression(el))
8686

8787
/**
8888
* Add attribute to an attributes object

Diff for: packages/babel-plugin-transform-vue-jsx/test/snapshot.js

+5
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ h("MyComponent", _mergeJSXProps([{
325325
}
326326
}]));`,
327327
},
328+
{
329+
name: 'JSX comments',
330+
from: `<div><p>jsx</p>{/* <p>comment</p> */}</div>`,
331+
to: `h("div", [h("p", ["jsx"])]);`
332+
}
328333
]
329334

330335
tests.forEach(({ name, from, to }) => test(name, async t => t.is(await transpile(from), to)))

0 commit comments

Comments
 (0)