single-file-core 1.5.33 → 1.5.35

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/core/index.js CHANGED
@@ -179,7 +179,7 @@ class Runner {
179
179
  this.options.url = this.options.url || (rootDocDefined && this.options.doc.documentURI);
180
180
  const matchResourceReferrer = this.options.url.match(/^.*\//);
181
181
  this.options.resourceReferrer = this.options.passReferrerOnError && matchResourceReferrer && matchResourceReferrer[0];
182
- this.options.baseURI = rootDocDefined && this.options.doc.baseURI;
182
+ this.options.baseURI = rootDocDefined && (testValidURL(this.options.doc.baseURI) ? this.options.doc.baseURI : this.options.url);
183
183
  this.options.rootDocument = root;
184
184
  this.options.updatedResources = this.options.updatedResources || {};
185
185
  this.options.fontTests = new Map();
@@ -788,7 +788,7 @@ class Processor {
788
788
  const attributeValue = videoElement.getAttribute(util.VIDEO_ATTRIBUTE_NAME);
789
789
  if (attributeValue) {
790
790
  const videoData = this.options.videos[Number(attributeValue)];
791
- const src = videoData.src || videoElement.src;
791
+ const src = (videoData && videoData.src) || videoElement.src;
792
792
  if (videoElement && src) {
793
793
  const linkElement = this.doc.createElement("a");
794
794
  const imgElement = this.doc.createElement("img");
@@ -912,7 +912,11 @@ class Processor {
912
912
  try {
913
913
  templateElement.replaceWith(placeHolderElement);
914
914
  } catch (error) {
915
- // ignored
915
+ if (originalElement) {
916
+ templateElement.replaceWith(originalElement);
917
+ } else {
918
+ templateElement.remove();
919
+ }
916
920
  }
917
921
  }
918
922
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.33",
3
+ "version": "1.5.35",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -50,8 +50,7 @@ async function display(document, docContent, { disableFramePointerEvents } = {})
50
50
  element.parentElement.replaceChild(noscriptElement, element);
51
51
  });
52
52
  document.documentElement.setAttribute("data-sfz", "");
53
- document.querySelectorAll("link[rel*=icon]").forEach(element => element.parentElement.replaceChild(element, element));
54
-
53
+ document.querySelectorAll("link[rel*=icon]").forEach(element => element.replaceWith(element.cloneNode(true)));
55
54
  function getDoctypeString(doc) {
56
55
  const docType = doc.doctype;
57
56
  let docTypeString = "";
package/single-file.js CHANGED
@@ -48,7 +48,13 @@ function init(initOptions) {
48
48
  }
49
49
  }
50
50
 
51
- async function getPageData(options = {}, initOptions, doc = globalThis.document, win = globalThis) {
51
+ async function getPageData(options = {}, initOptions, doc, win) {
52
+ if (doc === undefined) {
53
+ doc = globalThis.document;
54
+ }
55
+ if (win === undefined) {
56
+ win = globalThis;
57
+ }
52
58
  const frames = processors.frameTree;
53
59
  let framesSessionId;
54
60
  init(initOptions);