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(
587
587
return null ;
588
588
}
589
589
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 ;
593
596
}
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 ) ;
595
605
const headRoot : Document = getDocumentFromRoot ( resourceRoot ) ;
596
606
const headResources = getResourcesFromRoot ( headRoot ) . head ;
597
- const key = getTitleKey ( child ) ;
607
+ const key = getTitleKey ( childString ) ;
598
608
let resource = headResources . get ( key ) ;
599
609
if ( ! resource ) {
600
- const titleProps = titlePropsFromRawProps ( child , pendingProps ) ;
610
+ const titleProps = titlePropsFromRawProps ( childString , pendingProps ) ;
601
611
resource = {
602
612
type : 'title ',
603
613
props : titleProps ,
Original file line number Diff line number Diff line change @@ -1463,8 +1463,14 @@ function pushTitleImpl(
1463
1463
Array . isArray ( children ) && children . length < 2
1464
1464
? children [ 0 ] || null
1465
1465
: 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 ) ) ) ;
1468
1474
}
1469
1475
target . push ( endTag1 , stringToChunk ( 'title' ) , endTag2 ) ;
1470
1476
return null ;
You can’t perform that action at this time.
0 commit comments