changeset 2646:dc08127a5084

#9: Use DOMParser to conver HTML string to DOM for injection
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 19 Jan 2017 15:49:33 +0000
parents 130ae66c3b25
children 83ae42eab960
files js/core.js
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Thu Jan 19 15:46:17 2017 +0000
+++ b/js/core.js	Thu Jan 19 15:49:33 2017 +0000
@@ -635,9 +635,10 @@
     this.postNode = function () {
         // This will take the node from the popupOptions and display it
         var node = this.popupOptions[this.currentIndex],
-            converter = new showdown.Converter();
+            converter = new showdown.Converter(),
+            p = new DOMParser();
         this.popupResponse.innerHTML = "";
-        this.popupTitle = converter.makeHtml(node.specification.statement);
+        this.popupTitle = p.parseFromString(converter.makeHtml(node.specification.statement), "text/html").getElementsByTagName("body")[0].firstElementChild;
         if (node.specification.type == 'question') {
             var textArea = document.createElement('textarea');
             switch (node.specification.boxsize) {