67
67
* @typedef {JSX.Element | string | null | undefined } Child
68
68
* Child.
69
69
*
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
71
71
* Properties and children.
72
72
*
73
73
* @callback Create
@@ -260,7 +260,7 @@ export function toJsxRuntime(tree, options) {
260
260
return state . create (
261
261
tree ,
262
262
state . Fragment ,
263
- { children : result ? [ result ] : [ ] } ,
263
+ { children : result ? [ result ] : undefined } ,
264
264
undefined
265
265
)
266
266
}
@@ -296,7 +296,7 @@ function one(state, node, key) {
296
296
let type = state . Fragment
297
297
298
298
if ( node . type === 'element' ) {
299
- if ( tableElements . has ( node . tagName ) ) {
299
+ if ( children && tableElements . has ( node . tagName ) ) {
300
300
children = children . filter ( ( child ) => ! whitespace ( child ) )
301
301
}
302
302
@@ -340,7 +340,7 @@ function productionCreate(_, jsx, jsxs) {
340
340
return create
341
341
/** @type {Create } */
342
342
function create ( _ , type , props , key ) {
343
- const isStaticChildren = props . children . length > 1
343
+ const isStaticChildren = props . children ? props . children . length > 1 : false
344
344
const fn = isStaticChildren ? jsxs : jsx
345
345
return fn ( type , props , key )
346
346
}
@@ -358,7 +358,7 @@ function developmentCreate(filePath, jsxDEV) {
358
358
return create
359
359
/** @type {Create } */
360
360
function create ( node , type , props , key ) {
361
- const isStaticChildren = props . children . length > 1
361
+ const isStaticChildren = props . children ? props . children . length > 1 : false
362
362
const point = pointStart ( node )
363
363
return jsxDEV (
364
364
type ,
@@ -382,7 +382,7 @@ function developmentCreate(filePath, jsxDEV) {
382
382
* Info passed around.
383
383
* @param {Parent } node
384
384
* Current element.
385
- * @returns {Array<Child> }
385
+ * @returns {Array<Child> | undefined }
386
386
* Children.
387
387
*/
388
388
function createChildren ( state , node ) {
@@ -407,7 +407,7 @@ function createChildren(state, node) {
407
407
if ( result !== undefined ) children . push ( result )
408
408
}
409
409
410
- return children
410
+ return children . length > 0 ? children : undefined
411
411
}
412
412
413
413
/**
0 commit comments