We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A sequence of multiple self closing tags can be parsed. Example:
<circle id="pointA" cx="100" cy="350" r="3" /> <circle id="pointB" cx="200" cy="200" r="3" />
<tag1 /> <tag2 />
seem to be parsed as:
<tag1> <tag2> </tag2> </tag1>
so tag2 becomes a child of tag1.
For example try:
parse('<circle id="pointA" cx="100" cy="350" r="3" /><circle id="pointB" cx="200" cy="200" r="3" />')
I wonder if maybe this could be a domparser issue, not specific of this repo.
https://stackblitz.com/edit/react-he4dd8?file=src%2FApp.js
The text was updated successfully, but these errors were encountered:
Thanks for opening this issue @m3m0m2! Can you provide a reproducible example via StackBlitz JavaScript or TypeScript?
Sorry, something went wrong.
Can you provide a reproducible example via StackBlitz?
Done, updated description.
Thanks for the reproducible example. This is indeed a bug and it's happening in html-dom-parser.
The current workaround, like you noted in StackBlitz, is to not use self-closing tag:
<circle id="pointA" cx="100" cy="350" r="3"></circle> <circle id="pointB" cx="200" cy="200" r="3"></circle>
I'm not sure how to fix this issue since html-dom-parser uses innerHTML and this is the browser behavior.
innerHTML
@m3m0m2 Actually if your HTML string contains a parent, this might fix your issue: https://stackblitz.com/edit/html-react-parser-1434?file=src%2FApp.js
Let me know if this works:
const svgLines = ` <svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <circle cx="30" cy="30" r="10" stroke="black" fill="transparent" stroke-width="5" /> <circle cx="60" cy="60" r="10" stroke="black" fill="transparent" stroke-width="5" /> </svg> `; parse(svgLines);
remarkablemark
No branches or pull requests
Expected Behavior
A sequence of multiple self closing tags can be parsed.
Example:
Actual Behavior
seem to be parsed as:
so tag2 becomes a child of tag1.
Steps to Reproduce
For example try:
I wonder if maybe this could be a domparser issue, not specific of this repo.
Example in StackBlitz
https://stackblitz.com/edit/react-he4dd8?file=src%2FApp.js
The text was updated successfully, but these errors were encountered: