summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhackademix2018-07-09 00:09:34 +0200
committerhackademix2018-07-09 00:09:34 +0200
commit5217db79ce7db2a2d6e95483d3f6d9dad462a476 (patch)
tree214c8d96850ed658552739c6ad6f98cb8819b0e2 /src
parentdac392dedab6a4372d6e1d41483735d192e97eef (diff)
downloadnoscript-5217db79ce7db2a2d6e95483d3f6d9dad462a476.tar.gz
noscript-5217db79ce7db2a2d6e95483d3f6d9dad462a476.tar.xz
noscript-5217db79ce7db2a2d6e95483d3f6d9dad462a476.zip
Content-side DOM insertions made compatible with XML document.
Diffstat (limited to 'src')
-rw-r--r--src/content/PlaceHolder.js8
-rw-r--r--src/content/content.js4
-rw-r--r--src/content/onScriptDisabled.js2
3 files changed, 9 insertions, 5 deletions
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