From b33836fff11a7734aa31fdc5362ea29efe12a24d Mon Sep 17 00:00:00 2001 From: lengli Date: Wed, 26 Feb 2014 12:46:54 -0300 Subject: [PATCH] Error if element does't have style, it will throw an exception by trying to get textAlign --- docx.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docx.js b/docx.js index 3a93746..1571b5f 100644 --- a/docx.js +++ b/docx.js @@ -71,7 +71,7 @@ function convertContent(input) { 'use strict'; // Convert HTML to Wordprocessing for (i = 0; inNode = input.childNodes[i]; i++) { outNode = output.appendChild(newXMLnode('p')); pCount++; - if (inNode.style.textAlign) { outNode.appendChild(newXMLnode('pPr')).appendChild(newXMLnode('jc')).setAttribute('val', inNode.style.textAlign); } + if (inNode.style && inNode.style.textAlign) { outNode.appendChild(newXMLnode('pPr')).appendChild(newXMLnode('jc')).setAttribute('val', inNode.style.textAlign); } if (inNode.nodeName === '#text') { outNode.appendChild(newXMLnode('r')).appendChild(newXMLnode('t', inNode.nodeValue)); } else { for (j = 0; inNodeChild = inNode.childNodes[j]; j++) { @@ -169,4 +169,4 @@ function docx(file) { 'use strict'; // v1.0.1 } } return result; -} \ No newline at end of file +}