6767 * @typedef {JSX.Element | string | null | undefined } Child
6868 * Child.
6969 *
70- * @typedef {{children: Array<Child>, node?: Element | undefined, [prop: string]: Value | Element | undefined | Array<Child>} } Props
70+ * @typedef {{children: Array<Child> | undefined , node?: Element | undefined, [prop: string]: Value | Element | undefined | Array<Child>} } Props
7171 * Properties and children.
7272 *
7373 * @callback Create
@@ -260,7 +260,7 @@ export function toJsxRuntime(tree, options) {
260260 return state . create (
261261 tree ,
262262 state . Fragment ,
263- { children : result ? [ result ] : [ ] } ,
263+ { children : result ? [ result ] : undefined } ,
264264 undefined
265265 )
266266}
@@ -296,7 +296,7 @@ function one(state, node, key) {
296296 let type = state . Fragment
297297
298298 if ( node . type === 'element' ) {
299- if ( tableElements . has ( node . tagName ) ) {
299+ if ( children && tableElements . has ( node . tagName ) ) {
300300 children = children . filter ( ( child ) => ! whitespace ( child ) )
301301 }
302302
@@ -340,7 +340,7 @@ function productionCreate(_, jsx, jsxs) {
340340 return create
341341 /** @type {Create } */
342342 function create ( _ , type , props , key ) {
343- const isStaticChildren = props . children . length > 1
343+ const isStaticChildren = props . children ? props . children . length > 1 : false
344344 const fn = isStaticChildren ? jsxs : jsx
345345 return fn ( type , props , key )
346346 }
@@ -358,7 +358,7 @@ function developmentCreate(filePath, jsxDEV) {
358358 return create
359359 /** @type {Create } */
360360 function create ( node , type , props , key ) {
361- const isStaticChildren = props . children . length > 1
361+ const isStaticChildren = props . children ? props . children . length > 1 : false
362362 const point = pointStart ( node )
363363 return jsxDEV (
364364 type ,
@@ -382,7 +382,7 @@ function developmentCreate(filePath, jsxDEV) {
382382 * Info passed around.
383383 * @param {Parent } node
384384 * Current element.
385- * @returns {Array<Child> }
385+ * @returns {Array<Child> | undefined }
386386 * Children.
387387 */
388388function createChildren ( state , node ) {
@@ -407,7 +407,7 @@ function createChildren(state, node) {
407407 if ( result !== undefined ) children . push ( result )
408408 }
409409
410- return children
410+ return children . length > 0 ? children : undefined
411411}
412412
413413/**
0 commit comments