Parcourir la source

remove hidden iframes

Gildas il y a 7 ans
Parent
commit
ff57093143
1 fichiers modifiés avec 8 ajouts et 0 suppressions
  1. 8 0
      lib/single-file/doc-helper.js

+ 8 - 0
lib/single-file/doc-helper.js

@@ -77,6 +77,11 @@ this.docHelper = this.docHelper || (() => {
 					markHiddenCandidates(win, doc.body, styles, false, markerRemovedContent, new Set(), ignoredTags);
 					markHiddenElements(win, doc.body, styles, markerRemovedContent);
 					markBackdropBackground(doc, win, markerRemovedContent);
+					doc.querySelectorAll("iframe").forEach(element => {
+						if (testHiddenElement(element, styles.get(element))) {
+							element.srcdoc = "<html>";
+						}
+					});
 				}
 				if (options.removeAlternativeFonts) {
 					usedFonts = getUsedFonts(styles);
@@ -185,6 +190,9 @@ this.docHelper = this.docHelper || (() => {
 		if (!hidden && style) {
 			hidden = style.display == "none";
 			if (!hidden && (style.opacity == "0" || style.visibility == "hidden")) {
+				hidden = true;
+			}
+			if (!hidden) {
 				const boundingRect = element.getBoundingClientRect();
 				hidden = !boundingRect.width && !boundingRect.height;
 			}