html-react-parser
html-react-parser copied to clipboard
`value=` shouldn't be converted to `defaultValue=` for `<option>`
The value of <option> tags of <select> are fixed. Converting their value= to defaultValue= results bug if the option label is different from the value. For example:
<select name="range" value="gte-2">
<option value="lt-1">Less than 1</option>
<option value="gte-2">≥2<option>
</select>
The value of <select>'s "gte-2" won't get a match and it will fallback to "Less than 1".
https://github.com/remarkablemark/html-react-parser/blob/cffffc71fe8e72e6a662de50c0b00a3d77c60cc6/lib/attributes-to-props.js#L42-L49
Thanks for opening this issue @philiptzou.
What versions are you using (html-react-parser and react/react-dom) and can you provide a reproducible example?
@remarkablemark I already provided an example. I don't think the version is relevant since the current source code explicitly changed value to defaultValue. I have submitted a pull request.
Hey @remarkablemark, I have a question, but it's not related to this issue, I was looking for various alternatives, and found this package, I was thinking how this how package is different from Babel Transform, or jscodeshift?
@arpitBhalla for questions unrelated, do you mind creating a new issue? But to answer your current question, this package converts raw HTML string to React elements. If you're looking for something that generates an AST tree, then you can go with Babel or something else.
Thanks