From ba511e41eedbb41b619897d77916b41cf752af14 Mon Sep 17 00:00:00 2001 From: Jayesh Deorukhkar Date: Wed, 27 Sep 2023 13:53:40 +0530 Subject: [PATCH] feat: added proper type check for nodeValue --- src/fromRedactor.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fromRedactor.tsx b/src/fromRedactor.tsx index 7baa2ab..a634916 100644 --- a/src/fromRedactor.tsx +++ b/src/fromRedactor.tsx @@ -235,9 +235,12 @@ export const fromRedactor = (el: any, options?:IHtmlToJsonOptions) : IAnyObject const attributes = (el as HTMLElement).attributes const attributeMap = {} Array.from(attributes).forEach((attribute) => { - let { nodeName, value } = attribute - attributeMap[nodeName] = getNestedValueIfAvailable(value) - }) + let { nodeName, nodeValue } = attribute; + if (typeof nodeValue === "string") { + nodeValue = getNestedValueIfAvailable(nodeValue); + } + attributeMap[nodeName] = nodeValue; + }); console.warn(`${nodeName} is not a standard tag of JSON RTE.`) return jsx('element', { type: nodeName.toLowerCase(), attrs: { ...attributeMap } }, children) }