From dec67e3186e67e94773ea590d7ad4ba33b2fc571 Mon Sep 17 00:00:00 2001 From: glazar Date: Mon, 12 Jun 2017 10:50:31 +0300 Subject: [PATCH] Fix "Cannot read property text of undefined" Same code changes as found here https://github.com/istanbuljs-archived-repos/istanbul-reports/pull/10/commits/764cec03775dc3b7a812c6ff7782e011b8c85ca2 --- lib/report/html.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/report/html.js b/lib/report/html.js index 1dab26d5..485d22b5 100644 --- a/lib/report/html.js +++ b/lib/report/html.js @@ -202,7 +202,7 @@ function annotateStatements(fileCoverage, structuredText) { closeSpan = lt + '/span' + gt, text; - if (type === 'no') { + if (type === 'no' && structuredText[startLine]) { if (endLine !== startLine) { endLine = startLine; endCol = structuredText[startLine].text.originalLength(); @@ -233,7 +233,7 @@ function annotateFunctions(fileCoverage, structuredText) { closeSpan = lt + '/span' + gt, text; - if (type === 'no') { + if (type === 'no' && structuredText[startLine]) { if (endLine !== startLine) { endLine = startLine; endCol = structuredText[startLine].text.originalLength(); @@ -280,7 +280,7 @@ function annotateBranches(fileCoverage, structuredText) { openSpan = lt + 'span class="branch-' + i + ' ' + (meta.skip ? 'cbranch-skip' : 'cbranch-no') + '"' + title('branch not covered') + gt; closeSpan = lt + '/span' + gt; - if (count === 0) { //skip branches taken + if (count === 0 && structuredText[startLine]) { //skip branches taken if (endLine !== startLine) { endLine = startLine; endCol = structuredText[startLine].text.originalLength();