svg-exportJS
svg-exportJS copied to clipboard
bug: read viewbox correctly when it is defined with commas
Hello! Thanks for your module.
According to the view box definition https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox , the numbers could be separated with commas or spaces.
I was importing a d3 generated svg with viewBox="0,0,468,200" and the exported output was
viewBox="0,0,468,200 undefined 354 200"
Because the split function is only taking into account using spaces as dividers
_options.originalMinXViewBox = svgElement.getAttribute("viewBox") ? svgElement.getAttribute("viewBox").split(/\s/)[0] : 0;
_options.originalMinYViewBox = svgElement.getAttribute("viewBox") ? svgElement.getAttribute("viewBox").split(/\s/)[1] : 0;
With this change, it works for me with commas, spaces or both.