Skip to content

Commit ba511e4

Browse files
committed
feat: added proper type check for nodeValue
1 parent 3cf16bf commit ba511e4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/fromRedactor.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,12 @@ export const fromRedactor = (el: any, options?:IHtmlToJsonOptions) : IAnyObject
235235
const attributes = (el as HTMLElement).attributes
236236
const attributeMap = {}
237237
Array.from(attributes).forEach((attribute) => {
238-
let { nodeName, value } = attribute
239-
attributeMap[nodeName] = getNestedValueIfAvailable(value)
240-
})
238+
let { nodeName, nodeValue } = attribute;
239+
if (typeof nodeValue === "string") {
240+
nodeValue = getNestedValueIfAvailable(nodeValue);
241+
}
242+
attributeMap[nodeName] = nodeValue;
243+
});
241244
console.warn(`${nodeName} is not a standard tag of JSON RTE.`)
242245
return jsx('element', { type: nodeName.toLowerCase(), attrs: { ...attributeMap } }, children)
243246
}

0 commit comments

Comments
 (0)