jonathantneal / svg4everybody

Use external SVG spritemaps today
https://jonneal.dev/svg4everybody/
Other
3.29k stars 353 forks source link

images don't show within <svg> when forcing nosvg #107

Open jmp909 opened 8 years ago

jmp909 commented 8 years ago

when using nosvg: true it appears that images don't show because the browser isn't shwoing what's inside the <svg> tag. I can see the img is there in Inspector etc but the element shows blank

i did a quick test, replacing the svg with a div and this shows the image (but breaks a bunch of other things due to my layout)

// replace the <use> with the fallback image
// let's change this temporarily
//svg.replaceChild(img, use);

// create a div instead
var div = document.createElement('div');
// apend the image onto the div
div.appendChild(img);
// swap out the SVG for the div with the image in it
var pN = svg.parentNode;
pN.replaceChild(div, svg);

I'm not sure what the overall solution is to this, but I hope the information is useful. I guess you're not meant to force it if svg is supported?

thanks Joe