From cd7bea618341361cd563406d2141c7cd40790311 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Wed, 27 Aug 2014 14:17:33 +0200 Subject: [PATCH 1/3] Update parser.js Better than getting 0px width and height. Specs say that when they are missing we should consider 100%, in our case 100% will be 100px because we don't have anything to compare the SVG to before adding the SVG into a canvas. Otherwise we could take canvas widht and height. --- src/parser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parser.js b/src/parser.js index 9b6631b9..4a38d166 100644 --- a/src/parser.js +++ b/src/parser.js @@ -510,8 +510,8 @@ parseUseDirectives(doc); var viewBoxAttr = doc.getAttribute('viewBox'), - widthAttr = parseUnit(doc.getAttribute('width')), - heightAttr = parseUnit(doc.getAttribute('height')), + widthAttr = parseUnit(doc.getAttribute('width') || '100%'), + heightAttr = parseUnit(doc.getAttribute('height') || '100%'), viewBoxWidth, viewBoxHeight; From 4c4ba5bfe0b9ef40b18f722d1e7c7c954c1e7dc5 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Wed, 27 Aug 2014 23:09:31 +0200 Subject: [PATCH 2/3] Update parser.js Added comment for future reference --- src/parser.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/parser.js b/src/parser.js index 4a38d166..878c2f7c 100644 --- a/src/parser.js +++ b/src/parser.js @@ -508,7 +508,10 @@ var startTime = new Date(); parseUseDirectives(doc); - + /* http://www.w3.org/TR/SVG/struct.html#SVGElementWidthAttribute + * as per specs, width and height attributes are to be considered + * 100% if no value is specified. + */ var viewBoxAttr = doc.getAttribute('viewBox'), widthAttr = parseUnit(doc.getAttribute('width') || '100%'), heightAttr = parseUnit(doc.getAttribute('height') || '100%'), From b43492554a0d89aa45c97d6546ea439c833ce3f2 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Thu, 28 Aug 2014 00:04:07 +0200 Subject: [PATCH 3/3] Update parser.js Added comment for future reference --- src/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.js b/src/parser.js index 878c2f7c..f2f179c7 100644 --- a/src/parser.js +++ b/src/parser.js @@ -509,7 +509,7 @@ parseUseDirectives(doc); /* http://www.w3.org/TR/SVG/struct.html#SVGElementWidthAttribute - * as per specs, width and height attributes are to be considered + * as per spec, width and height attributes are to be considered * 100% if no value is specified. */ var viewBoxAttr = doc.getAttribute('viewBox'),