single-file-core 1.5.50 → 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/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);
|