1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 04:40:20 +01:00

Got rid of innerHTML - part 1.

This commit is contained in:
kkapsner 2017-10-10 13:38:55 +02:00
parent 4108d1a0e8
commit 932ec56079
2 changed files with 12 additions and 5 deletions

View File

@ -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;
});
};

View File

@ -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 = `<span class="more">${more}</span><span class="less">${less}</span>`;
["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(){