From 5217db79ce7db2a2d6e95483d3f6d9dad462a476 Mon Sep 17 00:00:00 2001 From: hackademix Date: Mon, 9 Jul 2018 00:09:34 +0200 Subject: Content-side DOM insertions made compatible with XML document. --- src/content/PlaceHolder.js | 8 ++++---- src/content/content.js | 4 ++++ src/content/onScriptDisabled.js | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/content') diff --git a/src/content/PlaceHolder.js b/src/content/PlaceHolder.js index 37c0198..ce579c2 100644 --- a/src/content/PlaceHolder.js +++ b/src/content/PlaceHolder.js @@ -87,23 +87,23 @@ var PlaceHolder = (() => { this.origin = new URL(url).origin; let TYPE = `<${this.policyType.toUpperCase()}>`; - let replacement = document.createElement("a"); + let replacement = createHTMLElement("a"); replacement.className = "__NoScript_PlaceHolder__"; cloneStyle(element, replacement); replacement.style.backgroundImage = `url(${ICON_URL})`; replacement.href = url; replacement.title = `${TYPE}@${url}`; - let inner = replacement.appendChild(document.createElement("span")); + let inner = replacement.appendChild(createHTMLElement("span")); inner.className = replacement.className; - let button = inner.appendChild(document.createElement("button")); + let button = inner.appendChild(createHTMLElement("button")); button.className = replacement.className; button.setAttribute("aria-label", button.title = _("Close")); button.value = "close"; button.textContent = "🗙"; - let description = inner.appendChild(document.createElement("span")); + let description = inner.appendChild(createHTMLElement("span")); description.textContent = `${TYPE}@${this.origin}`; replacement._placeHolderObj = this; diff --git a/src/content/content.js b/src/content/content.js index 5ba5076..a74aa0c 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -2,6 +2,10 @@ // debug = () => {}; // XPI_ONLY +function createHTMLElement(name) { + return document.createElementNS("http://www.w3.org/1999/xhtml", name); +} + var _ = browser.i18n.getMessage; var canScript = true; diff --git a/src/content/onScriptDisabled.js b/src/content/onScriptDisabled.js index 2c1c59c..45f1534 100644 --- a/src/content/onScriptDisabled.js +++ b/src/content/onScriptDisabled.js @@ -1,7 +1,7 @@ function onScriptDisabled() { for (let noscript of document.querySelectorAll("noscript")) { // force show NOSCRIPT elements content - let replacement = document.createElement("no-script"); + let replacement = createHTMLElement("no-script"); replacement.innerHTML = noscript.innerHTML; noscript.parentNode.replaceChild(replacement, noscript); // emulate meta-refresh -- cgit v1.2.3