-
Notifications
You must be signed in to change notification settings - Fork 32
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
Protocol Handler: SVG does not render when used in img HTML tag #54
Comments
No it's different from #52 as in this case they are under same protocol but different origins, created #55 to track that. |
Here is what I see observing the output produced:
I'll continue digging through this to better determine what is going on. |
Looking further into this it appears that maybe call to |
Turns if |
Thanks for looking into this. |
I have resolved #56 which should provide a way to address #56 as you pointed out. That being said I'd still keep this open as I would like to:
|
I did preliminary digging into |
It looks like if headers are omitted in HTTP server firefox correctly sniffs the content type, here is the code I used for testing: const http = require('http')
const server = http.createServer((request, response) => {
response.writeHead(200)
if (request.url.endsWith('dot.svg')) {
response.end(`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100px" height="150px" viewBox="0 0 10 15" enable-background="new 0 0 10 15" xml:space="preserve">
<g>
<path fill="#FFFFFF" d="M5,11c-1.929,0-3.5-1.571-3.5-3.5S3.071,4,5,4s3.5,1.571,3.5,3.5S6.929,11,5,11z"/>
<path fill="#808080" d="M5,4.588c1.609,0,2.912,1.303,2.912,2.912S6.609,10.412,5,10.412S2.088,9.109,2.088,7.5 S3.391,4.588,5,4.588 M5,3C2.519,3,0.5,5.019,0.5,7.5S2.519,12,5,12s4.5-2.019,4.5-4.5S7.481,3,5,3L5,3z"/>
</g>
</svg>`)
} else {
response.end(`<h1>HTML</h1><p><img src="dot.svg" alt="dot.svg" border="1" style="width:100px;height:150px;" /></p>`)
}
})
server.listen(8090) Digging through the |
I end up landing #60 to which does more or less what @lidel With this change your original example seems to work as expected. If I recall correctly you also mentioned to me in person that there was some issue with text file / or maybe markdown file mime type detection. I would expect this to be handled by this change as well. |
Ack, #60 fixed rendering of SVGs: Regarding Markdown: it opens fine if content type is set to |
Summary
SVG does not render in HTML when loaded via
<img src=
, even when loaded from the same origin.How to Reproduce
demo:protocol
from mysvg-render-bug-demo
branch:dweb://html/dot.svg
directly – it renders just fine. Test SVG comes from commons.dweb://html/
, you will see inline<svg>
rendering ok but external one loaded via<img src="dweb://html/dot.svg" />
(same origin) failing to load with errors in consoledweb://foo/
, you will see<img src="dweb://html/dot.svg" />
(loaded from different origin) fails to load just like in previous stepScreenshot
The text was updated successfully, but these errors were encountered: