From 99d3a234f4618d0baae9c56fbf35baab085d1f67 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 10 Oct 2020 21:07:54 +0000 Subject: [PATCH] Fix bug with rendering text nodes --- webclient/src/Article.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/webclient/src/Article.js b/webclient/src/Article.js index 5a363c8..6b41562 100644 --- a/webclient/src/Article.js +++ b/webclient/src/Article.js @@ -56,9 +56,9 @@ class Article extends React.Component { let nodes = null; if (story.text) { - let domparser = new DOMParser(); - let doc = domparser.parseFromString(story.text, 'text/html'); - nodes = doc.querySelector('body').children; + let div = document.createElement('div'); + div.innerHTML = story.text; + nodes = div.childNodes; } return ( @@ -86,10 +86,14 @@ class Article extends React.Component {

) : - <> - - {v.localName == 'pre' && } - + (v.nodeName === '#text' ? +

{v.data}

+ : + <> + + {v.localName == 'pre' && } + + ) )} :