Fixed soft reload messing with non UTF-8 encodings (thanks "Quest" for reporting).

This commit is contained in:
hackademix 2020-09-11 00:30:34 +02:00
parent 486da3bb0b
commit 911469eb27
1 changed files with 5 additions and 8 deletions

View File

@ -41,7 +41,6 @@
let softReload = ev => {
try {
//let html = document.documentElement.outerHTML;
debug("Soft reload", ev); // DEV_ONLY
try {
let doc = window.wrappedJSObject.document;
@ -52,15 +51,13 @@
if (isDir || document.contentType !== "text/html") {
throw new Error(`Can't document.write() on ${isDir ? "directory listings" : document.contentType}`)
}
DocumentFreezer.unfreeze();
let html = document.documentElement.outerHTML;
doc.open();
console.debug("Opened", doc.documentElement);
DocumentFreezer.unfreeze();
(async () => {
let html = await ((await fetch(document.URL)).text());
doc.write(html);
doc.close();
debug("Written", html)
})();
doc.write(html);
doc.close();
debug("Written", html);
} catch (e) {
debug("Can't use document.write(), XML document?", e);
try {