single-file-core 1.5.58 → 1.5.60
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 +8 -3
- package/core/index.js +1 -0
- package/core/util.js +6 -0
- package/package.json +2 -2
- package/single-file-editor-helper.js +6 -0
package/core/helper.js
CHANGED
|
@@ -106,6 +106,7 @@ export {
|
|
|
106
106
|
digest,
|
|
107
107
|
getValidFilename,
|
|
108
108
|
parseDocContent,
|
|
109
|
+
markInvalidNesting,
|
|
109
110
|
fixInvalidNesting,
|
|
110
111
|
ON_BEFORE_CAPTURE_EVENT_NAME,
|
|
111
112
|
ON_AFTER_CAPTURE_EVENT_NAME,
|
|
@@ -314,9 +315,11 @@ function markInvalidNesting(doc) {
|
|
|
314
315
|
}
|
|
315
316
|
}
|
|
316
317
|
|
|
317
|
-
function fixInvalidNesting(document, NESTING_TRACK_ID_ATTRIBUTE_NAME) {
|
|
318
|
+
function fixInvalidNesting(document, NESTING_TRACK_ID_ATTRIBUTE_NAME, preventCleanup = false) {
|
|
318
319
|
const trackIds = {};
|
|
319
|
-
document.currentScript
|
|
320
|
+
if (document.currentScript) {
|
|
321
|
+
document.currentScript.remove();
|
|
322
|
+
}
|
|
320
323
|
buildTrackIdMap(document.body);
|
|
321
324
|
Object.keys(trackIds).forEach(id => {
|
|
322
325
|
const element = trackIds[id];
|
|
@@ -329,7 +332,9 @@ function fixInvalidNesting(document, NESTING_TRACK_ID_ATTRIBUTE_NAME) {
|
|
|
329
332
|
}
|
|
330
333
|
}
|
|
331
334
|
});
|
|
332
|
-
|
|
335
|
+
if (!preventCleanup) {
|
|
336
|
+
document.querySelectorAll("[" + NESTING_TRACK_ID_ATTRIBUTE_NAME + "]").forEach(element => element.removeAttribute(NESTING_TRACK_ID_ATTRIBUTE_NAME));
|
|
337
|
+
}
|
|
333
338
|
|
|
334
339
|
function buildTrackIdMap(element) {
|
|
335
340
|
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,12 @@ function getInstance(utilOptions) {
|
|
|
129
129
|
return doc;
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
|
+
fixInvalidNesting(doc, preventCleanup = true) {
|
|
133
|
+
helper.fixInvalidNesting(doc, helper.NESTING_TRACK_ID_ATTRIBUTE_NAME, preventCleanup);
|
|
134
|
+
},
|
|
135
|
+
markInvalidNesting(doc) {
|
|
136
|
+
helper.markInvalidNesting(doc, helper.NESTING_TRACK_ID_ATTRIBUTE_NAME);
|
|
137
|
+
},
|
|
132
138
|
getFixInvalidNestingSource() {
|
|
133
139
|
return helper.fixInvalidNesting.toString().replace(/\s+/g, " ");
|
|
134
140
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "single-file-core",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.60",
|
|
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.
|
|
19
|
+
"eslint": "^9.39.1"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -46,6 +46,12 @@ const helper = {
|
|
|
46
46
|
displayIcon(doc, useShadowRoot, options = {}) {
|
|
47
47
|
return infobar.displayIcon(doc, useShadowRoot, options);
|
|
48
48
|
},
|
|
49
|
+
fixInvalidNesting(document, preventCleanup = false) {
|
|
50
|
+
return util.fixInvalidNesting(document, preventCleanup);
|
|
51
|
+
},
|
|
52
|
+
markInvalidNesting(document) {
|
|
53
|
+
return util.markInvalidNesting(document);
|
|
54
|
+
},
|
|
49
55
|
zip,
|
|
50
56
|
extract,
|
|
51
57
|
display,
|