From b538a875091b83784139f1dea4068a6ed8c17303 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Wed, 9 Apr 2014 07:42:46 +0800 Subject: [PATCH] Handle null values (along with undefined) in jspdf.plugin.svgToPdf.js --- jspdf.plugin.svgToPdf.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jspdf.plugin.svgToPdf.js b/jspdf.plugin.svgToPdf.js index 89c42f9c8..8bc9157d6 100644 --- a/jspdf.plugin.svgToPdf.js +++ b/jspdf.plugin.svgToPdf.js @@ -46,7 +46,7 @@ var svgElementToPdf = function(element, pdf, options) { $(element).children().each(function(i, node) { var n = $(node); if (n.is("g")) { - if (n.attr('transform') !== undefined) { + if (n.attr('transform') != null) { var matrix = n.attr('transform').replace(/,/g, ' ').replace('matrix(', '').replace(')', ' cm'); pdf.internal.write('q'); pdf.internal.write(matrix); @@ -62,7 +62,7 @@ var svgElementToPdf = function(element, pdf, options) { if (n.is('g,line,rect,ellipse,circle,text,path')) { var fillColor = n.attr('fill'); - if (typeof(fillColor) != 'undefined') { + if (fillColor != null) { var fillRGB = new RGBColor(fillColor); if (fillRGB.ok) { @@ -81,7 +81,7 @@ var svgElementToPdf = function(element, pdf, options) { } var strokeColor = n.attr('stroke'); - if (typeof(strokeColor) != 'undefined' && strokeColor !== 'none') { + if (strokeColor != null && strokeColor !== 'none') { var strokeRGB = new RGBColor(strokeColor); if (strokeRGB.ok) { @@ -108,7 +108,7 @@ var svgElementToPdf = function(element, pdf, options) { k * parseInt(n.attr('y2'))); // $.each(node.attributes, function(i, a) { - // if(typeof(a) != 'undefined' && pdfSvgAttr.line.indexOf(a.name.toLowerCase()) == -1) { + // if(a != null && pdfSvgAttr.line.indexOf(a.name.toLowerCase()) == -1) { // node.removeAttribute(a.name); // } // }); @@ -122,7 +122,7 @@ var svgElementToPdf = function(element, pdf, options) { k * parseInt(n.attr('height')), colorMode); // $.each(node.attributes, function(i, a) { - // if(typeof(a) != 'undefined' && pdfSvgAttr.rect.indexOf(a.name.toLowerCase()) == -1) { + // if(a != null && pdfSvgAttr.rect.indexOf(a.name.toLowerCase()) == -1) { // node.removeAttribute(a.name); // } // }); @@ -135,7 +135,7 @@ var svgElementToPdf = function(element, pdf, options) { k * parseInt(n.attr('ry')), colorMode); // $.each(node.attributes, function(i, a) { - // if(typeof(a) != 'undefined' && pdfSvgAttr.ellipse.indexOf(a.name.toLowerCase()) == -1) { + // if(a != null && pdfSvgAttr.ellipse.indexOf(a.name.toLowerCase()) == -1) { // node.removeAttribute(a.name); // } // }); @@ -147,7 +147,7 @@ var svgElementToPdf = function(element, pdf, options) { k * parseInt(n.attr('r')), colorMode); // $.each(node.attributes, function(i, a) { - // if(typeof(a) != 'undefined' && pdfSvgAttr.circle.indexOf(a.name.toLowerCase()) == -1) { + // if(a != null && pdfSvgAttr.circle.indexOf(a.name.toLowerCase()) == -1) { // node.removeAttribute(a.name); // } // }); @@ -245,7 +245,7 @@ var svgElementToPdf = function(element, pdf, options) { k * y, text_value); // $.each(node.attributes, function(i, a) { - // if(typeof(a) != 'undefined' && pdfSvgAttr.text.indexOf(a.name.toLowerCase()) == -1) { + // if(a != null && pdfSvgAttr.text.indexOf(a.name.toLowerCase()) == -1) { // node.removeAttribute(a.name); // } // });