exupero / saveSvgAsPng

Save SVGs as PNGs from the browser.
MIT License
1.09k stars 362 forks source link

TypeError: Cannot read property 'replace' of null #210

Closed TKirahvi closed 5 years ago

TKirahvi commented 5 years ago

RROR Error: Uncaught (in promise): TypeError: Cannot read property 'replace' of null TypeError: Cannot read property 'replace' of null at saveSvgAsPng.js:258

There is no transform attribute in my svg and still the code tries to get that attribute without null check. Fixed it with this:

if ( clone.getAttribute('transform') != null ) { clone.setAttribute('transform', clone.getAttribute('transform').replace(/translate\(.*?\)/, '')); }

exupero commented 5 years ago

Thanks! Just published v1.4.12 with your fix.