7979 * @typedef {JSX.Element | string | null | undefined } Child
8080 * Child.
8181 *
82- * @typedef {{children: Array<Child> | undefined , node?: Element | undefined, [prop: string]: Value | Element | undefined | Array<Child>} } Props
82+ * @typedef {{children? : Array<Child> | Child , node?: Element | undefined, [prop: string]: Value | Element | undefined | Child | Array<Child>} } Props
8383 * Properties and children.
8484 *
8585 * @callback Create
@@ -295,7 +295,7 @@ export function toJsxRuntime(tree, options) {
295295 return state . create (
296296 tree ,
297297 state . Fragment ,
298- { children : result ? [ result ] : undefined } ,
298+ { children : result || undefined } ,
299299 undefined
300300 )
301301}
@@ -348,7 +348,13 @@ function one(state, node, key) {
348348 }
349349 }
350350
351- props . children = children
351+ if ( children . length > 0 ) {
352+ const value = children . length > 1 ? children : children [ 0 ]
353+
354+ if ( value ) {
355+ props . children = value
356+ }
357+ }
352358
353359 // Restore parent schema.
354360 state . schema = parentSchema
@@ -375,7 +381,8 @@ function productionCreate(_, jsx, jsxs) {
375381 return create
376382 /** @type {Create } */
377383 function create ( _ , type , props , key ) {
378- const isStaticChildren = props . children ? props . children . length > 1 : false
384+ // Only an array when there are 2 or more children.
385+ const isStaticChildren = Array . isArray ( props . children )
379386 const fn = isStaticChildren ? jsxs : jsx
380387 return key ? fn ( type , props , key ) : fn ( type , props )
381388 }
@@ -393,7 +400,8 @@ function developmentCreate(filePath, jsxDEV) {
393400 return create
394401 /** @type {Create } */
395402 function create ( node , type , props , key ) {
396- const isStaticChildren = props . children ? props . children . length > 1 : false
403+ // Only an array when there are 2 or more children.
404+ const isStaticChildren = Array . isArray ( props . children )
397405 const point = pointStart ( node )
398406 return jsxDEV (
399407 type ,
@@ -417,7 +425,7 @@ function developmentCreate(filePath, jsxDEV) {
417425 * Info passed around.
418426 * @param {Parent } node
419427 * Current element.
420- * @returns {Array<Child> | undefined }
428+ * @returns {Array<Child> }
421429 * Children.
422430 */
423431function createChildren ( state , node ) {
@@ -444,7 +452,7 @@ function createChildren(state, node) {
444452 if ( result !== undefined ) children . push ( result )
445453 }
446454
447- return children . length > 0 ? children : undefined
455+ return children
448456}
449457
450458/**
@@ -459,7 +467,7 @@ function createChildren(state, node) {
459467 */
460468function createProperties ( state , node ) {
461469 /** @type {Props } */
462- const props = { children : [ ] }
470+ const props = { }
463471 /** @type {string } */
464472 let prop
465473
0 commit comments