single-file-core 1.2.12 → 1.2.13
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 +3 -3
- package/core/index.js +1 -3
- package/package.json +1 -1
package/core/helper.js
CHANGED
|
@@ -203,12 +203,12 @@ function preProcessDoc(doc, win, options) {
|
|
|
203
203
|
|
|
204
204
|
function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map(), canvases: [], images: [], posters: [], videos: [], shadowRoots: [], markedElements: [] }, ascendantHidden) {
|
|
205
205
|
if (element.childNodes) {
|
|
206
|
-
const elements = Array.from(element.childNodes).filter(node => (node instanceof win.HTMLElement) || (node instanceof win.SVGElement));
|
|
206
|
+
const elements = Array.from(element.childNodes).filter(node => (node instanceof win.HTMLElement) || (node instanceof win.SVGElement) || (node instanceof globalThis.HTMLElement) || (node instanceof globalThis.SVGElement));
|
|
207
207
|
elements.forEach(element => {
|
|
208
208
|
let elementHidden, elementKept, computedStyle;
|
|
209
209
|
if (!options.autoSaveExternalSave && (options.removeHiddenElements || options.removeUnusedFonts || options.compressHTML)) {
|
|
210
210
|
computedStyle = getComputedStyle(win, element);
|
|
211
|
-
if (element instanceof win.HTMLElement) {
|
|
211
|
+
if ((element instanceof win.HTMLElement) || (element instanceof globalThis.HTMLElement)) {
|
|
212
212
|
if (options.removeHiddenElements) {
|
|
213
213
|
elementKept = ((ascendantHidden || element.closest("html > head")) && KEPT_TAG_NAMES.includes(element.tagName.toUpperCase())) || element.closest("details");
|
|
214
214
|
if (!elementKept) {
|
|
@@ -237,7 +237,7 @@ function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
getResourcesInfo(win, doc, element, options, data, elementHidden, computedStyle);
|
|
240
|
-
const shadowRoot = !(element instanceof win.SVGElement) && getShadowRoot(element);
|
|
240
|
+
const shadowRoot = !((element instanceof win.SVGElement) || (element instanceof globalThis.SVGElement)) && getShadowRoot(element);
|
|
241
241
|
if (shadowRoot && !element.classList.contains(SINGLE_FILE_UI_ELEMENT_CLASS)) {
|
|
242
242
|
const shadowRootInfo = {};
|
|
243
243
|
element.setAttribute(SHADOW_ROOT_ATTRIBUTE_NAME, data.shadowRoots.length);
|
package/core/index.js
CHANGED
|
@@ -588,9 +588,7 @@ class Processor {
|
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
preProcessPage() {
|
|
591
|
-
|
|
592
|
-
this.doc.body.querySelectorAll(":not(svg) title, meta, link[href][rel*=\"icon\"]").forEach(element => element instanceof this.options.win.HTMLElement && this.doc.head.appendChild(element));
|
|
593
|
-
}
|
|
591
|
+
this.doc.body.querySelectorAll(":not(svg) title, meta, link[href][rel*=\"icon\"]").forEach(element => ((element instanceof (this.options.win && this.options.win.HTMLElement)) || (element instanceof globalThis.HTMLElement)) && this.doc.head.appendChild(element));
|
|
594
592
|
if (this.options.images && !this.options.saveRawPage) {
|
|
595
593
|
this.doc.querySelectorAll("img[" + util.IMAGE_ATTRIBUTE_NAME + "]").forEach(imgElement => {
|
|
596
594
|
const attributeValue = imgElement.getAttribute(util.IMAGE_ATTRIBUTE_NAME);
|