File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
packages/react-dom-bindings/src Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -587,17 +587,27 @@ export function getResource(
587587 return null ;
588588 }
589589 case 'title ': {
590- let child = pendingProps . children ;
591- if ( Array . isArray ( child ) && child . length === 1 ) {
592- child = child [ 0 ] ;
590+ const children = pendingProps . children ;
591+ let child ;
592+ if ( Array . isArray ( children ) && children . length === 1 ) {
593+ child = children [ 0 ] ;
594+ } else {
595+ child = children ;
593596 }
594- if ( typeof child === 'string ' || typeof child === 'number ') {
597+ if (
598+ typeof child !== 'function ' &&
599+ typeof child !== 'symbol ' &&
600+ child !== null &&
601+ child !== undefined
602+ ) {
603+ // eslint-disable-next-line react-internal/safe-string-coercion
604+ const childString = '' + ( child : any ) ;
595605 const headRoot : Document = getDocumentFromRoot ( resourceRoot ) ;
596606 const headResources = getResourcesFromRoot ( headRoot ) . head ;
597- const key = getTitleKey ( child ) ;
607+ const key = getTitleKey ( childString ) ;
598608 let resource = headResources . get ( key ) ;
599609 if ( ! resource ) {
600- const titleProps = titlePropsFromRawProps ( child , pendingProps ) ;
610+ const titleProps = titlePropsFromRawProps ( childString , pendingProps ) ;
601611 resource = {
602612 type : 'title ',
603613 props : titleProps ,
Original file line number Diff line number Diff line change @@ -1463,8 +1463,14 @@ function pushTitleImpl(
14631463 Array . isArray ( children ) && children . length < 2
14641464 ? children [ 0 ] || null
14651465 : children ;
1466- if ( typeof child === 'string' || typeof child === 'number' ) {
1467- target . push ( stringToChunk ( escapeTextForBrowser ( child ) ) ) ;
1466+ if (
1467+ typeof child !== 'function' &&
1468+ typeof child !== 'symbol' &&
1469+ child !== null &&
1470+ child !== undefined
1471+ ) {
1472+ // eslint-disable-next-line react-internal/safe-string-coercion
1473+ target . push ( stringToChunk ( escapeTextForBrowser ( '' + child ) ) ) ;
14681474 }
14691475 target . push ( endTag1 , stringToChunk ( 'title' ) , endTag2 ) ;
14701476 return null ;
You can’t perform that action at this time.
0 commit comments