@@ -300,9 +300,13 @@ const handleClientStateChange = (newState) => {
300
300
} ) ;
301
301
} ;
302
302
303
+ const flattenArray = ( possibleArray ) => {
304
+ return Array . isArray ( possibleArray ) ? possibleArray . join ( "" ) : possibleArray ;
305
+ } ;
306
+
303
307
const updateTitle = ( title , attributes ) => {
304
308
if ( typeof title !== "undefined" && document . title !== title ) {
305
- document . title = Array . isArray ( title ) ? title . join ( "" ) : title ;
309
+ document . title = flattenArray ( title ) ;
306
310
}
307
311
308
312
updateAttributes ( TAG_NAMES . TITLE , attributes ) ;
@@ -410,9 +414,10 @@ const generateElementAttributesAsString = (attributes) => Object.keys(attributes
410
414
411
415
const generateTitleAsString = ( type , title , attributes , encode ) => {
412
416
const attributeString = generateElementAttributesAsString ( attributes ) ;
417
+ const flattenedTitle = flattenArray ( title ) ;
413
418
return attributeString
414
- ? `<${ type } ${ HELMET_ATTRIBUTE } ="true" ${ attributeString } >${ encodeSpecialCharacters ( title , encode ) } </${ type } >`
415
- : `<${ type } ${ HELMET_ATTRIBUTE } ="true">${ encodeSpecialCharacters ( title , encode ) } </${ type } >` ;
419
+ ? `<${ type } ${ HELMET_ATTRIBUTE } ="true" ${ attributeString } >${ encodeSpecialCharacters ( flattenedTitle , encode ) } </${ type } >`
420
+ : `<${ type } ${ HELMET_ATTRIBUTE } ="true">${ encodeSpecialCharacters ( flattenedTitle , encode ) } </${ type } >` ;
416
421
} ;
417
422
418
423
const generateTagsAsString = ( type , tags , encode ) => tags . reduce ( ( str , tag ) => {
0 commit comments