Skip to content
New issue

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

Parsing SVGs adds additional tags around the parsed data. #1040

Closed
timmy-wright opened this issue Sep 6, 2023 · 3 comments
Closed

Parsing SVGs adds additional tags around the parsed data. #1040

timmy-wright opened this issue Sep 6, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@timmy-wright
Copy link
Contributor

timmy-wright commented Sep 6, 2023

Describe the bug
Parsing SVGs using:
parser.parseFromString(svg, "image/svg+xml");
adds HTML and BODY tags around the SVG.

Wheras doing this using JSDOM or in the browser console does not add the additional tags. This means happy-dom is not a drop-replacement for jsdom and does not emulate browser behaviour.

To Reproduce

See git repo here with jsdom and happydom examples:
https://github.com/drtimwright/happy-dom-tests/tree/main/src

I'd expect this command to return "svg" not "html":

new DOMParser().parseFromString("<svg><g></g></svg>", "image/svg+xml").getRootNode().childNodes[0].nodeName;

Expected behavior

  • parsing XML that is not HTML should not add HTML tags.

Device:

  • OS: Windows (but probably all)
  • Browser N/A
  • Version: 10.11.2

Additional context
I'll try to make a PR for this, but no promises!

@timmy-wright timmy-wright added the bug Something isn't working label Sep 6, 2023
@timmy-wright
Copy link
Contributor Author

image

timmy-wright added a commit to timmy-wright/happy-dom that referenced this issue Sep 6, 2023
capricorn86 added a commit that referenced this issue Sep 14, 2023
#1040@minor: Don't add HTML tags when parsing SVGs.
@capricorn86
Copy link
Owner

@drtimwright your fix has been released 🙂

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v11.1.1

@timmy-wright
Copy link
Contributor Author

Awesome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants