single-file-core 1.5.49 → 1.5.51
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 +15 -12
- package/modules/template-formatter.js +2 -1
- package/package.json +1 -1
package/core/index.js
CHANGED
|
@@ -578,7 +578,6 @@ class Processor {
|
|
|
578
578
|
styleElement.textContent = "img[src=\"data:,\"],source[src=\"data:,\"]{display:none!important}";
|
|
579
579
|
this.doc.head.appendChild(styleElement);
|
|
580
580
|
}
|
|
581
|
-
this.doc.head.querySelectorAll("noscript").forEach(element => element.parentElement.appendChild(element));
|
|
582
581
|
let size;
|
|
583
582
|
if (this.options.displayStats) {
|
|
584
583
|
size = util.getContentSize(this.doc.documentElement.outerHTML);
|
|
@@ -853,18 +852,22 @@ class Processor {
|
|
|
853
852
|
|
|
854
853
|
removeDiscardedResources() {
|
|
855
854
|
this.doc.querySelectorAll("." + util.SINGLE_FILE_UI_ELEMENT_CLASS).forEach(element => element.remove());
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
855
|
+
if (this.options.removeNoScriptTags === false) {
|
|
856
|
+
const noscriptPlaceholders = new Map();
|
|
857
|
+
this.doc.querySelectorAll("noscript").forEach(noscriptElement => {
|
|
858
|
+
const placeholderElement = this.doc.createElement("div");
|
|
859
|
+
placeholderElement.innerHTML = noscriptElement.dataset[util.NO_SCRIPT_PROPERTY_NAME];
|
|
860
|
+
noscriptElement.replaceWith(placeholderElement);
|
|
861
|
+
noscriptPlaceholders.set(placeholderElement, noscriptElement);
|
|
862
|
+
});
|
|
863
|
+
noscriptPlaceholders.forEach((noscriptElement, placeholderElement) => {
|
|
864
|
+
noscriptElement.dataset[util.NO_SCRIPT_PROPERTY_NAME] = placeholderElement.innerHTML;
|
|
865
|
+
placeholderElement.replaceWith(noscriptElement);
|
|
866
|
+
});
|
|
867
|
+
} else {
|
|
868
|
+
this.doc.querySelectorAll("noscript").forEach(element => element.remove());
|
|
869
|
+
}
|
|
863
870
|
this.doc.querySelectorAll("meta[http-equiv=refresh], meta[disabled-http-equiv]").forEach(element => element.remove());
|
|
864
|
-
noscriptPlaceholders.forEach((noscriptElement, placeholderElement) => {
|
|
865
|
-
noscriptElement.dataset[util.NO_SCRIPT_PROPERTY_NAME] = placeholderElement.innerHTML;
|
|
866
|
-
placeholderElement.replaceWith(noscriptElement);
|
|
867
|
-
});
|
|
868
871
|
this.doc.querySelectorAll("meta[http-equiv=\"content-security-policy\"]").forEach(element => element.remove());
|
|
869
872
|
const objectElements = this.doc.querySelectorAll("applet, object[data]:not([type=\"image/svg+xml\"]):not([type=\"image/svg-xml\"]):not([type=\"text/html\"]):not([data*=\".svg\"]):not([data*=\".pdf\"]), embed[src]:not([src*=\".svg\"]):not([src*=\".pdf\"])");
|
|
870
873
|
this.stats.set("discarded", "objects", objectElements.length);
|
|
@@ -17097,7 +17097,8 @@ async function evalTemplate(template = "", options, content, doc, context = {})
|
|
|
17097
17097
|
}
|
|
17098
17098
|
optionalArguments = optionalArguments
|
|
17099
17099
|
.map(argument => argument.replace(/\\\\(.)/g, "$1"))
|
|
17100
|
-
.filter(argument => argument != undefined && argument != null
|
|
17100
|
+
.filter(argument => argument != undefined && argument != null)
|
|
17101
|
+
.map(argument => argument == "" ? undefined : argument);
|
|
17101
17102
|
if ((argument != undefined && argument != null && argument != "") || optionalArguments.length > 0) {
|
|
17102
17103
|
try {
|
|
17103
17104
|
const dontReplaceSlash = fn.dontReplaceSlash === undefined ? true : fn.dontReplaceSlash;
|