@@ -352,23 +352,24 @@ function generateSymbolsDiv(target, width, height, symbols, text, defaultScale,
352352 let iconsHeight = height ;
353353 let textWidth = width ;
354354 let textHeight = height ;
355- text = String ( text ) ;
356- if ( text ) {
355+ const hasText = text !== undefined && text !== null && text !== '' ;
356+ const normalizedText = hasText ? String ( text ) : '' ;
357+ if ( hasText ) {
357358 outerWrapper . classList . add ( 'withText' ) ;
358359 if ( width / height >= 2 ) {
359360 outerWrapper . classList . add ( 'textRight' ) ;
360361 iconsWidth = iconsHeight ;
361362 textWidth = width - iconsWidth
362363 } else {
363364 outerWrapper . classList . add ( 'textBottom' ) ;
364- iconsHeight = iconsHeight / ( text . indexOf ( '\n' ) != - 1 ? 3 : 2 ) ;
365+ iconsHeight = iconsHeight / ( normalizedText . indexOf ( '\n' ) != - 1 ? 3 : 2 ) ;
365366 textHeight = height - iconsHeight
366367 }
367368 wrapper . style . setProperty ( '--width' , `${ iconsWidth } px` ) ;
368369 wrapper . style . setProperty ( '--height' , `${ iconsHeight } px` ) ;
369370 $ ( '.symbolText' , outerWrapper ) . style . setProperty ( '--color' , `${ defaultColor } ` ) ;
370371 $ ( '.symbolText' , outerWrapper ) . style . setProperty ( '--hoverColor' , `${ defaultHoverColor } ` ) ;
371- setTextAndAdjustFontSize ( $ ( '.symbolText' , outerWrapper ) , text , textWidth , textHeight ) ;
372+ setTextAndAdjustFontSize ( $ ( '.symbolText' , outerWrapper ) , normalizedText , textWidth , textHeight ) ;
372373 }
373374 const maxSize = optimalSquareSize ( asArray ( symbols ) . length , iconsWidth , iconsHeight ) ;
374375
@@ -441,4 +442,4 @@ function generateSymbolsDiv(target, width, height, symbols, text, defaultScale,
441442 }
442443
443444 return outerWrapper ;
444- }
445+ }
0 commit comments