|
|
@@ -134,7 +134,8 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
{ action: "replaceStylesheets" },
|
|
|
{ action: "replaceStyleAttributes" },
|
|
|
{ action: "insertVariables" },
|
|
|
- { option: "compressHTML", action: "compressHTML" }
|
|
|
+ { option: "compressHTML", action: "compressHTML" },
|
|
|
+ { action: "cleanupPage" }
|
|
|
],
|
|
|
parallel: [
|
|
|
{ option: "enableMaff", action: "insertMAFFMetaData" },
|
|
|
@@ -198,7 +199,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
await this.pendingPromises;
|
|
|
await this.executeStage(REPLACE_DOCS_STAGE);
|
|
|
await this.executeStage(POST_PROCESS_STAGE);
|
|
|
- await this.processor.finalize();
|
|
|
+ this.processor.finalize();
|
|
|
}
|
|
|
|
|
|
getDocument() {
|
|
|
@@ -401,18 +402,10 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
this.onEventAttributeNames = Util.getOnEventAttributeNames(this.doc);
|
|
|
}
|
|
|
|
|
|
- async finalize() {
|
|
|
+ finalize() {
|
|
|
if (this.workStyleElement.parentNode) {
|
|
|
this.workStyleElement.remove();
|
|
|
}
|
|
|
- this.doc.querySelectorAll("base").forEach(element => element.remove());
|
|
|
- const metaCharset = this.doc.head.querySelector("meta[charset]");
|
|
|
- if (metaCharset) {
|
|
|
- this.doc.head.insertBefore(metaCharset, this.doc.head.firstChild);
|
|
|
- if (this.doc.head.querySelectorAll("*").length == 1 && this.doc.body.childNodes.length == 0) {
|
|
|
- this.doc.head.querySelector("meta[charset]").remove();
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
async getPageData() {
|
|
|
@@ -1216,6 +1209,17 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ cleanupPage() {
|
|
|
+ this.doc.querySelectorAll("base").forEach(element => element.remove());
|
|
|
+ const metaCharset = this.doc.head.querySelector("meta[charset]");
|
|
|
+ if (metaCharset) {
|
|
|
+ this.doc.head.insertBefore(metaCharset, this.doc.head.firstChild);
|
|
|
+ if (this.doc.head.querySelectorAll("*").length == 1 && this.doc.body.childNodes.length == 0) {
|
|
|
+ this.doc.head.querySelector("meta[charset]").remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
async insertMAFFMetaData() {
|
|
|
const maffMetaData = await this.maffMetaDataPromise;
|
|
|
if (maffMetaData && maffMetaData.content) {
|