Sfoglia il codice sorgente

empty frame src if hidden

Gildas 6 anni fa
parent
commit
75e18d2caf
1 ha cambiato i file con 13 aggiunte e 16 eliminazioni
  1. 13 16
      lib/single-file/util/doc-helper.js

+ 13 - 16
lib/single-file/util/doc-helper.js

@@ -119,19 +119,19 @@ this.docHelper = this.docHelper || (() => {
 					elementHidden = ascendantHidden || testHiddenElement(element, computedStyle);
 				}
 				if (!elementHidden) {
-				if (options.compressHTML) {
-					const whiteSpace = computedStyle.getPropertyValue("white-space");
-					if (whiteSpace.startsWith("pre")) {
-						element.setAttribute(PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME, "");
+					if (options.compressHTML) {
+						const whiteSpace = computedStyle.getPropertyValue("white-space");
+						if (whiteSpace.startsWith("pre")) {
+							element.setAttribute(PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME, "");
+						}
+					}
+					if (options.removeUnusedFonts) {
+						getUsedFont(computedStyle, options, data.usedFonts);
+						getUsedFont(win.getComputedStyle(element, ":first-letter"), options, data.usedFonts);
+						getUsedFont(win.getComputedStyle(element, ":before"), options, data.usedFonts);
+						getUsedFont(win.getComputedStyle(element, ":after"), options, data.usedFonts);
 					}
 				}
-				if (options.removeUnusedFonts) {
-					getUsedFont(computedStyle, options, data.usedFonts);
-					getUsedFont(win.getComputedStyle(element, ":first-letter"), options, data.usedFonts);
-					getUsedFont(win.getComputedStyle(element, ":before"), options, data.usedFonts);
-					getUsedFont(win.getComputedStyle(element, ":after"), options, data.usedFonts);
-				}
-			}
 			}
 			getResourcesInfo(win, doc, element, options, data, elementHidden);
 			if (element.shadowRoot) {
@@ -195,11 +195,8 @@ this.docHelper = this.docHelper || (() => {
 			}
 		}
 		if (element.tagName == "IFRAME") {
-			if (element.getBoundingClientRect) {
-				const boundingRect = element.getBoundingClientRect();
-				if (element.hidden || element.style.display == "none" || boundingRect.width <= 1 && boundingRect.height <= 1) {
-					element.setAttribute(REMOVED_CONTENT_ATTRIBUTE_NAME, "");
-				}
+			if (elementHidden) {
+				element.setAttribute("src", "data:text/html,");
 			}
 		}
 	}