From 732adfa710298a29e749be000cae4008ee8cba14 Mon Sep 17 00:00:00 2001 From: Gaurish Kamat <34893664+gaurishk23@users.noreply.github.com> Date: Tue, 21 May 2019 11:54:36 +0530 Subject: [PATCH 1/2] Update DocPreprocessor.js Added check for the body length. The code breaks if the body in table data is empty. --- src/DocPreprocessor.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/DocPreprocessor.js b/src/DocPreprocessor.js index ad114d944..43da0c670 100644 --- a/src/DocPreprocessor.js +++ b/src/DocPreprocessor.js @@ -96,21 +96,22 @@ class DocPreprocessor { let cols; let rows; - for (col = 0, cols = node.table.body[0].length; col < cols; col++) { - for (row = 0, rows = node.table.body.length; row < rows; row++) { - let rowData = node.table.body[row]; - let data = rowData[col]; - if (data !== undefined) { - if (data === null) { // transform to object - data = ''; - } - if (!data._span) { - rowData[col] = this.preprocessNode(data); + if(node && node.table && Array.isArray(node.table.body) && node.table.body.length ){ + for (col = 0, cols = node.table.body[0].length; col < cols; col++) { + for (row = 0, rows = node.table.body.length; row < rows; row++) { + let rowData = node.table.body[row]; + let data = rowData[col]; + if (data !== undefined) { + if (data === null) { // transform to object + data = ''; + } + if (!data._span) { + rowData[col] = this.preprocessNode(data); + } } } } } - return node; } From e6c5d7b96e0dbe4c393a693709f0bf8d19c41807 Mon Sep 17 00:00:00 2001 From: Gaurish Kamat <34893664+gaurishk23@users.noreply.github.com> Date: Tue, 21 May 2019 12:03:16 +0530 Subject: [PATCH 2/2] Update DocPreprocessor.js --- src/DocPreprocessor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocPreprocessor.js b/src/DocPreprocessor.js index 43da0c670..bc96e4e5e 100644 --- a/src/DocPreprocessor.js +++ b/src/DocPreprocessor.js @@ -96,7 +96,7 @@ class DocPreprocessor { let cols; let rows; - if(node && node.table && Array.isArray(node.table.body) && node.table.body.length ){ + if(node && node.table && isArray(node.table.body) && node.table.body.length ){ for (col = 0, cols = node.table.body[0].length; col < cols; col++) { for (row = 0, rows = node.table.body.length; row < rows; row++) { let rowData = node.table.body[row];