single-file-core 1.5.58 → 1.5.59

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/helper.js CHANGED
@@ -314,9 +314,11 @@ function markInvalidNesting(doc) {
314
314
  }
315
315
  }
316
316
 
317
- function fixInvalidNesting(document, NESTING_TRACK_ID_ATTRIBUTE_NAME) {
317
+ function fixInvalidNesting(document, NESTING_TRACK_ID_ATTRIBUTE_NAME, preventCleanup = false) {
318
318
  const trackIds = {};
319
- document.currentScript.remove();
319
+ if (document.currentScript) {
320
+ document.currentScript.remove();
321
+ }
320
322
  buildTrackIdMap(document.body);
321
323
  Object.keys(trackIds).forEach(id => {
322
324
  const element = trackIds[id];
@@ -329,7 +331,9 @@ function fixInvalidNesting(document, NESTING_TRACK_ID_ATTRIBUTE_NAME) {
329
331
  }
330
332
  }
331
333
  });
332
- Object.keys(trackIds).forEach(id => trackIds[id].removeAttribute(NESTING_TRACK_ID_ATTRIBUTE_NAME));
334
+ if (!preventCleanup) {
335
+ Object.keys(trackIds).forEach(id => trackIds[id].removeAttribute(NESTING_TRACK_ID_ATTRIBUTE_NAME));
336
+ }
333
337
 
334
338
  function buildTrackIdMap(element) {
335
339
  const id = element.getAttribute(NESTING_TRACK_ID_ATTRIBUTE_NAME);
package/core/index.js CHANGED
@@ -470,6 +470,7 @@ class Processor {
470
470
  pageContent = content.data || "";
471
471
  }
472
472
  this.doc = util.parseDocContent(pageContent, this.baseURI);
473
+ util.fixInvalidNesting(this.doc);
473
474
  if (this.options.saveRawPage) {
474
475
  let charset;
475
476
  this.doc.querySelectorAll("meta[charset]").forEach(element => {
package/core/util.js CHANGED
@@ -129,6 +129,9 @@ function getInstance(utilOptions) {
129
129
  return doc;
130
130
  }
131
131
  },
132
+ fixInvalidNesting(doc) {
133
+ helper.fixInvalidNesting(doc, helper.NESTING_TRACK_ID_ATTRIBUTE_NAME, true);
134
+ },
132
135
  getFixInvalidNestingSource() {
133
136
  return helper.fixInvalidNesting.toString().replace(/\s+/g, " ");
134
137
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.58",
3
+ "version": "1.5.59",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -16,6 +16,6 @@
16
16
  },
17
17
  "homepage": "https://github.com/gildas-lormeau/single-file-core#readme",
18
18
  "devDependencies": {
19
- "eslint": "^9.38.0"
19
+ "eslint": "^9.39.1"
20
20
  }
21
21
  }