single-file-core 1.0.65 → 1.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.0.65",
3
+ "version": "1.0.66",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -494,9 +494,6 @@ class Processor {
494
494
  );
495
495
  this.doc.documentElement.insertBefore(commentNode, this.doc.documentElement.firstChild);
496
496
  }
497
- if (this.options.includeInfobar) {
498
- util.appendInfobar(this.doc, this.options);
499
- }
500
497
  if (this.doc.querySelector("template[" + SHADOWROOT_ATTRIBUTE_NAME + "]") || (this.options.shadowRoots && this.options.shadowRoots.length)) {
501
498
  if (this.options.blockScripts) {
502
499
  this.doc.querySelectorAll("script[" + SCRIPT_TEMPLATE_SHADOW_ROOT + "]").forEach(element => element.remove());
@@ -867,9 +864,9 @@ class Processor {
867
864
  }
868
865
 
869
866
  saveFavicon() {
870
- let faviconElement = this.doc.querySelector("link[href][rel=\"icon\"]");
867
+ let faviconElement = this.doc.querySelector("link[href][rel=\"shortcut icon\"]");
871
868
  if (!faviconElement) {
872
- faviconElement = this.doc.querySelector("link[href][rel=\"shortcut icon\"]");
869
+ faviconElement = this.doc.querySelector("link[href][rel=\"icon\"]");
873
870
  }
874
871
  if (!faviconElement) {
875
872
  faviconElement = this.doc.createElement("link");
@@ -1167,6 +1164,13 @@ class Processor {
1167
1164
  if (shadowRootData) {
1168
1165
  const templateElement = doc.createElement("template");
1169
1166
  templateElement.setAttribute(SHADOWROOT_ATTRIBUTE_NAME, shadowRootData.mode);
1167
+ if (shadowRootData.adoptedStyleSheets) {
1168
+ shadowRootData.adoptedStyleSheets.forEach(stylesheetContent => {
1169
+ const styleElement = doc.createElement("style");
1170
+ styleElement.textContent = stylesheetContent;
1171
+ templateElement.appendChild(styleElement);
1172
+ });
1173
+ }
1170
1174
  const shadowDoc = util.parseDocContent(shadowRootData.content);
1171
1175
  if (shadowDoc.head) {
1172
1176
  const metaCharset = shadowDoc.head.querySelector("meta[charset]");
@@ -1184,13 +1188,6 @@ class Processor {
1184
1188
  } else {
1185
1189
  element.appendChild(templateElement);
1186
1190
  }
1187
- if (shadowRootData.adoptedStyleSheets) {
1188
- shadowRootData.adoptedStyleSheets.forEach(stylesheetContent => {
1189
- const styleElement = doc.createElement("style");
1190
- styleElement.textContent = stylesheetContent;
1191
- templateElement.appendChild(styleElement);
1192
- });
1193
- }
1194
1191
  }
1195
1192
  }
1196
1193
  });
@@ -1516,11 +1513,14 @@ class ProcessorHelper {
1516
1513
  }
1517
1514
 
1518
1515
  static processShortcutIcons(doc) {
1519
- let shortcutIcon = findShortcutIcon(Array.from(doc.querySelectorAll("link[href][rel=\"icon\"], link[href][rel=\"shortcut icon\"]")));
1516
+ let shortcutIcon = findShortcutIcon(Array.from(doc.querySelectorAll("link[href][rel=\"shortcut icon\"]")));
1517
+ if (!shortcutIcon) {
1518
+ shortcutIcon = findShortcutIcon(Array.from(doc.querySelectorAll("link[href][rel=\"icon\"]")));
1519
+ }
1520
1520
  if (!shortcutIcon) {
1521
1521
  shortcutIcon = findShortcutIcon(Array.from(doc.querySelectorAll("link[href][rel*=\"icon\"]")));
1522
1522
  if (shortcutIcon) {
1523
- shortcutIcon.rel = "icon";
1523
+ shortcutIcon.rel = "shortcut icon";
1524
1524
  }
1525
1525
  }
1526
1526
  if (shortcutIcon) {
@@ -23,11 +23,16 @@
23
23
 
24
24
  import * as serializer from "./modules/html-serializer.js";
25
25
  import * as infobar from "./common/infobar.js";
26
+ import { getInstance } from "./single-file-util.js";
26
27
 
28
+ const util = getInstance();
27
29
  const helper = {
28
30
  serialize(doc, compressHTML) {
29
31
  return serializer.process(doc, compressHTML);
30
32
  },
33
+ getDoctypeString(doc) {
34
+ return util.getDoctypeString(doc);
35
+ },
31
36
  appendInfobar(doc, options, useShadowRoot) {
32
37
  return infobar.appendInfobar(doc, options, useShadowRoot);
33
38
  },