Skip to content

Commit

Permalink
Enhance truncateNames function to handle null text content
Browse files Browse the repository at this point in the history
  • Loading branch information
icycoldveins committed Feb 3, 2024
1 parent 3c4a341 commit 9a58930
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion community-website/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export function truncateNames():void {
if (subscriptElementsArray !== null) {
subscriptElementsArray.forEach((subscriptElement) => {
const wordLength = subscriptElement?.textContent?.length || 0;
if (wordLength> 13) {
if (wordLength === 0) return; // Skip elements without text content
if (wordLength > 13) {
subscriptElement.innerHTML = "<b>" + subscriptElement?.textContent?.substr(0, 10) + "..." + "</b>";
}
})
Expand Down

0 comments on commit 9a58930

Please sign in to comment.