Skip to content

Commit 1a0607d

Browse files
committed
Fix a few exceptions noticed when running the default test suite against the Babel plugin
1 parent 129e793 commit 1a0607d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/babel-plugin-htm/index.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export default function htmBabelPlugin({ types: t }, options = {}) {
7171
}
7272

7373
function propsNode(props) {
74+
if (props == null) return t.nullLiteral();
75+
7476
return t.isNode(props) ? props : t.objectExpression(
7577
Object.keys(props).map(key => {
7678
let value = props[key];
@@ -85,7 +87,11 @@ export default function htmBabelPlugin({ types: t }, options = {}) {
8587
);
8688
}
8789

88-
function transform({ tag, props, children }, state) {
90+
function transform(node, state) {
91+
if (node === undefined) return t.identifier('undefined');
92+
if (node == null) return t.nullLiteral();
93+
94+
const { tag, props, children } = node;
8995
function childMapper(child) {
9096
if (typeof child==='string') {
9197
return stringValue(child);

0 commit comments

Comments
 (0)