Content-side DOM insertions made compatible with XML document.

This commit is contained in:
hackademix 2018-07-09 00:09:34 +02:00
parent dac392deda
commit 5217db79ce
3 changed files with 9 additions and 5 deletions

View File

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

View File

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

View File

@ -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