Skip to content

Commit

Permalink
feat: added proper type check for nodeValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayesh2812 committed Sep 27, 2023
1 parent 3cf16bf commit ba511e4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/fromRedactor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit ba511e4

Please sign in to comment.