HAST node array property value is serialized
subhero24 opened this issue · 3 comments
This issue is related to #14 regarding the properties of React elements.
My node has properties like:
{
params: ["param1", "param2", "param3"]
}These lines in hast-to-hyperscript serializes the array into a string
if (value !== null && typeof value === 'object' && 'length' in value) {
// Accept `array`. Most props are space-separater.
value = (info.commaSeparated ? commas : spaces).stringify(value)
}As was the case with the false values in #14 , when dealing with react elements, I would expect the properties to apply to the react element as-is. So that the react elements receive the actual properties that are present in the HAST.
Would it be possible to not transform the properties in case of react elements?
Could you expand on how you use this library / HAST / unified?
I’m feeling this is not that similar to GH-14, because in that issue, false was used on valid HTML properties, which React did not work with properly.
Actual arrays on valid HTML properties do not make sense, because they are always stringified.
So I’m thinking you’re using HAST to represent something that isn’t HTML (but e.g., a react component, which is not what it’s supposed to do)
I think you are right. I should use a superset of HAST to represent react components. Thanks for you comment!
Yeah it’s hard I think because HAST is really for HTML, but people are using it for non-HTML things a lot. But if we support more non-HTML things, we also break compat with HTML, which I’d rather not do.
Please do keep on raising issues for similar things though, I appreciate that!