From 932ec5607981b453ba5d41f22c550c9353f7bd5d Mon Sep 17 00:00:00 2001 From: kkapsner Date: Tue, 10 Oct 2017 13:38:55 +0200 Subject: [PATCH] Got rid of innerHTML - part 1. --- pageAction/domainNotification.js | 4 ++-- pageAction/gui.js | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pageAction/domainNotification.js b/pageAction/domainNotification.js index 3eb9c34..a57dccf 100644 --- a/pageAction/domainNotification.js +++ b/pageAction/domainNotification.js @@ -84,7 +84,7 @@ node.appendChild(document.createTextNode(" (")); var countSpan = document.createElement("span"); countSpan.className = "count"; - countSpan.innerHTML = "0"; + countSpan.textContent = "0"; node.appendChild(countSpan); node.appendChild(document.createTextNode(") ")); @@ -107,7 +107,7 @@ }).join("\n"); node.querySelectorAll(".count").forEach(function(countSpan){ - countSpan.innerHTML = notifications.length; + countSpan.textContent = notifications.length; }); }; diff --git a/pageAction/gui.js b/pageAction/gui.js index ba8db62..6fa1f99 100644 --- a/pageAction/gui.js +++ b/pageAction/gui.js @@ -10,14 +10,21 @@ const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = require("./logging"); scope.createCollapser = function(){ - const more = browser.i18n.getMessage("more"); - const less = browser.i18n.getMessage("less"); + const messages = { + more: browser.i18n.getMessage("more"), + less: browser.i18n.getMessage("less") + }; return function createCollapser(container){ var collapser = document.createElement("span"); collapser.className = "collapser"; - collapser.innerHTML = `${more}${less}`; + ["more", "less"].forEach(function(type){ + var span = document.createElement("span"); + span.className = type; + span.textContent = messages[type]; + collapser.appendChild(span); + }); container.appendChild(collapser); collapser.addEventListener("click", function(){