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

Fix error when showing some special svg due to data url #450

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cesaryuan
Copy link

Close: #449

The bug https://bugzilla.mozilla.org/show_bug.cgi?id=1125667 in the code comment seems have been fixed.
image

So, it's time to use blob urls. It will resolve the bug #449.

Copy link

netlify bot commented Sep 9, 2024

Deploy Preview for svgomg ready!

Name Link
🔨 Latest commit f9af6dc
🔍 Latest deploy log https://app.netlify.com/sites/svgomg/deploys/66de8f24700512000802ff6a
😎 Deploy Preview https://deploy-preview-450--svgomg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jakearchibald
Copy link
Owner

Thanks for this! Does the SVG in #449 fail due to its size?

@cesaryuan
Copy link
Author

Thanks for this! Does the SVG in #449 fail due to its size?

I have no idea for this😂

@zunsthy
Copy link

zunsthy commented Oct 16, 2024

Thanks for this! Does the SVG in #449 fail due to its size?

no, #449 problem is because of no "xmlns" attribute. it's ok after toggle off the option "remove xmlns".

browser can't display normally "image/svg+xml" lack of "xmlns" attribute.

for example https://bugzilla.mozilla.org/show_bug.cgi?id=1125667

it works

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<defs><circle cx="50" cy="50" r="50" id="circle" /></defs>
<use href="#circle"/>
</svg>

it doesn't work

<svg width="100" height="100">
<defs><circle cx="50" cy="50" r="50" id="circle" /></defs>
<use href="#circle"/>
</svg>

i think need use 'text/html' as iframe source type, like this:

if (noXMLNS) {
   this._svgFrame.src = `data:text/html,${encodeURIComponent(`<html><head><style>body{margin:0}</style></head><body>${text}</body></html>`}`;
} else {
   this._svgFrame.src = URL.createObjectURL(new Blob([text], { type: 'image/svg+xml' }));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot show some special svg
3 participants