From 9162b4ca254efcfa422e50418be1b5bcfc00d28a Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Wed, 23 Oct 2024 18:26:07 +0100 Subject: [PATCH] fix: skip undefined when extracting text --- framework/core/js/src/common/utils/extractText.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/core/js/src/common/utils/extractText.ts b/framework/core/js/src/common/utils/extractText.ts index ac5bc3a48e..e72cd13014 100644 --- a/framework/core/js/src/common/utils/extractText.ts +++ b/framework/core/js/src/common/utils/extractText.ts @@ -5,7 +5,10 @@ import type Mithril from 'mithril'; */ export default function extractText(vdom: Mithril.Children): string { if (vdom instanceof Array) { - return vdom.map((element) => extractText(element)).join(''); + return vdom + .filter((item) => item !== undefined) + .map((element) => extractText(element)) + .join(''); } else if (typeof vdom === 'object' && vdom !== null) { return extractText(vdom.children); } else {