From 4c2b2342212033f53b70b914d640266e8de9b2c4 Mon Sep 17 00:00:00 2001 From: Bo Zhang Date: Mon, 26 Jul 2021 08:27:45 +0800 Subject: [PATCH] fix(helper): add fallback to avoid undefined TypeError In some cases, `strLines` can be `undefined` along some code path in `pushTokens`, resulting in undefined TypeError. --- src/graphic/helper/parseText.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/graphic/helper/parseText.ts b/src/graphic/helper/parseText.ts index a928552d6..6158f2d64 100644 --- a/src/graphic/helper/parseText.ts +++ b/src/graphic/helper/parseText.ts @@ -533,6 +533,11 @@ function pushTokens( strLines = str.split('\n'); } + // fallback in case of undefined exception + if (strLines === undefined) { + strLines = str.split('\n') + } + for (let i = 0; i < strLines.length; i++) { const text = strLines[i]; const token = new RichTextToken();