Description
The current implementation is missing some of the edge cases when converting from HTML to react. Examples:
- We need to add
key
attributes if an element has siblings
- Handle the
aria-*
and SVG props correctly
- Preserve custom attributes correctly (to handle webcomponents)
Examples
https://github.com/remarkablemark/html-react-parser
Possible solution
A possible solution is to re-use the attributesToProps
function from:
Additionally, there is some potential for code reuse from: https://github.com/remarkablemark/html-react-parser/blob/master/lib/dom-to-react.js
@mmczaplinski i think it also needs eg itemProp, itemType, itemScope. When I pulled these out of my database as the lowercase versions on a span or div etc React complained as they didn’t get converted
I’m not sure what the full list is but those are the main 3 I use
https://schema.org/docs/gs.html
I added my own processor for now to get rid of the errors using eg
if(node.props['itemtype']) {
node.props.itemType = node.props['itemtype']
delete node.props['itemtype']
}
I don’t know if that’s how I should do it, but as mentioned it removes the error.
Thanks
J
Note: issue raised at add schema attributes to Html2React · Issue #854 · frontity/frontity · GitHub