I have the following code:
const svg = new Image();
svg.src = "https://svgur.com/i/soR.svg";
const ctx = document.querySelector("canvas").getContext("2d");
function drawImage() {
ctx.drawImage(svg, 0, 0);
requestAnimationFrame(drawImage);
}
requestAnimationFrame(drawImage);
<canvas></canvas>
If you run this in Chrome or Safari or Edge, a lamb is rendered to the canvas.
However, in Firefox, this does not occur.
If I give the svg file a width and height value, then it renders in Firefox, however, I do not want to do this. I only wish to use viewBox
, and I have hundreds of SVGs, and I really, really do not want to manually calculate and add width
and height
values to each one.
Is there a way to get this SVG to render in Firefox without modifying the SVG?