From 541bd0c70111189065ed61a52baac56a0436381b Mon Sep 17 00:00:00 2001 From: Ilya Zub Date: Fri, 31 Jul 2020 15:49:39 +0300 Subject: [PATCH] Fix "TypeError: Cannot set property 'border' of undefined" In this conditional current node is a text node (`nodeType === 3`). It doesn't have style attribute. It's parent has. --- struktur.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/struktur.js b/struktur.js index 38dce68..9084a81 100644 --- a/struktur.js +++ b/struktur.js @@ -349,10 +349,10 @@ function struktur(config = {}) { 'text': currentNode.data.trim() }; if (this.config.addClass) { - obj.class = currentNode.parentElement.classList.toString(); + obj.class = parent.classList.toString(); } if (this.config.highlightContent) { - currentNode.style.border = "1px solid rgb(255, 0, 0)"; + parent.style.border = "1px solid rgb(255, 0, 0)"; } this.parsed.push(obj); } @@ -405,4 +405,4 @@ function struktur(config = {}) { let struktur = new Struktur(config); return JSON.stringify(struktur.struktur(), null, 2); -} \ No newline at end of file +}