|
|
@@ -89,7 +89,6 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
{ option: "selected", action: "removeUnselectedElements" },
|
|
|
{ option: "removeVideoSrc", action: "insertVideoPosters" },
|
|
|
{ option: "removeFrames", action: "removeFrames" },
|
|
|
- { option: "removeImports", action: "removeImports" },
|
|
|
{ option: "removeScripts", action: "removeScripts" },
|
|
|
{ option: "removeVideoSrc", action: "removeVideoSources" },
|
|
|
{ option: "removeAudioSrc", action: "removeAudioSources" },
|
|
|
@@ -107,7 +106,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
parallel: [
|
|
|
{ action: "resolveStylesheetURLs" },
|
|
|
{ option: "!removeFrames", action: "resolveFrameURLs" },
|
|
|
- { option: "!removeImports", action: "resolveHtmlImportURLs" }
|
|
|
+ { action: "resolveHtmlImportURLs" }
|
|
|
]
|
|
|
}, {
|
|
|
sequential: [
|
|
|
@@ -963,9 +962,17 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
const processor = new Runner(options);
|
|
|
this.relImportProcessors.set(linkElement, processor);
|
|
|
await processor.loadPage();
|
|
|
- return processor.initialize();
|
|
|
+ await processor.initialize();
|
|
|
+ processor.processor.stylesheets.forEach(stylesheet => {
|
|
|
+ const importedStyleElement = this.doc.createElement("style");
|
|
|
+ linkElement.insertAdjacentElement("afterEnd", importedStyleElement);
|
|
|
+ this.stylesheets.set(importedStyleElement, stylesheet);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
+ if (options.removeImports) {
|
|
|
+ linkElement.remove();
|
|
|
+ }
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
@@ -1100,18 +1107,8 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
if (processor) {
|
|
|
this.stats.add("processed", "HTML imports", 1);
|
|
|
this.relImportProcessors.delete(linkElement);
|
|
|
+ await processor.run();
|
|
|
const pageData = await processor.getPageData();
|
|
|
- processor.getDocument().querySelectorAll("style").forEach(styleElement => {
|
|
|
- const stylesheet = processor.processor.stylesheets.get(styleElement);
|
|
|
- if (stylesheet) {
|
|
|
- const importedStyleElement = this.doc.createElement("style");
|
|
|
- importedStyleElement.media = styleElement.media;
|
|
|
- importedStyleElement.textContent = styleElement.textContent;
|
|
|
- linkElement.parentElement.insertBefore(importedStyleElement, linkElement);
|
|
|
- const stylesheet = processor.processor.stylesheets.get(styleElement);
|
|
|
- this.stylesheets.set(importedStyleElement, stylesheet);
|
|
|
- }
|
|
|
- });
|
|
|
linkElement.setAttribute("href", "data:text/html," + pageData.content);
|
|
|
this.stats.addAll(pageData);
|
|
|
} else {
|