Improved NOSCRIPT element emulation compatibility with XML documents.
This commit is contained in:
parent
ba5db52fd2
commit
ad926dbc31
|
@ -8,7 +8,8 @@ function onScriptDisabled() {
|
||||||
for (let noscript of document.querySelectorAll("noscript")) {
|
for (let noscript of document.querySelectorAll("noscript")) {
|
||||||
|
|
||||||
// force show NOSCRIPT elements content
|
// force show NOSCRIPT elements content
|
||||||
let replacement = document.createRange().createContextualFragment(noscript.innerHTML);
|
let replacement = createHTMLElement("span");
|
||||||
|
replacement.innerHTML = noscript.innerHTML;
|
||||||
// emulate meta-refresh
|
// emulate meta-refresh
|
||||||
for (let meta of replacement.querySelectorAll('meta[http-equiv="refresh"]')) {
|
for (let meta of replacement.querySelectorAll('meta[http-equiv="refresh"]')) {
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
@ -25,9 +26,13 @@ function onScriptDisabled() {
|
||||||
let html = document.documentElement.outerHTML;
|
let html = document.documentElement.outerHTML;
|
||||||
let rewrite = () => {
|
let rewrite = () => {
|
||||||
let document = window.wrappedJSObject ? window.wrappedJSObject.document : window.document;
|
let document = window.wrappedJSObject ? window.wrappedJSObject.document : window.document;
|
||||||
|
try {
|
||||||
document.open();
|
document.open();
|
||||||
document.write(html);
|
document.write(html);
|
||||||
document.close();
|
document.close();
|
||||||
|
} catch (e) {
|
||||||
|
error(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (document.readyState === "complete") {
|
if (document.readyState === "complete") {
|
||||||
rewrite();
|
rewrite();
|
||||||
|
@ -52,7 +57,7 @@ function onScriptDisabled() {
|
||||||
addEventListener("keyup", ev => {
|
addEventListener("keyup", ev => {
|
||||||
if (!ev.isTrusted) return;
|
if (!ev.isTrusted) return;
|
||||||
let el = eraser.tapped;
|
let el = eraser.tapped;
|
||||||
if (el && ev.keyCode === 46) {
|
if (el && ev.code === "Delete" || ev.code === "Backspace") {
|
||||||
eraser.tapped = null;
|
eraser.tapped = null;
|
||||||
eraser.delKey = true;
|
eraser.delKey = true;
|
||||||
let doc = el.ownerDocument;
|
let doc = el.ownerDocument;
|
||||||
|
|
Loading…
Reference in New Issue