Prechádzať zdrojové kódy

ensure getBoundingClientRect exists

Gildas 7 rokov pred
rodič
commit
d546ff16b0
1 zmenil súbory, kde vykonal 6 pridanie a 4 odobranie
  1. 6 4
      lib/single-file/util/doc-helper.js

+ 6 - 4
lib/single-file/util/doc-helper.js

@@ -74,9 +74,11 @@ this.docHelper = this.docHelper || (() => {
 					markHiddenCandidates(win, doc.body, elementsInfo, false, markerRemovedContent, new Set(), ignoredTags);
 					markHiddenElements(win, doc.body, markerRemovedContent);
 					doc.querySelectorAll("iframe").forEach(element => {
-						const boundingRect = element.getBoundingClientRect();
-						if (element.hidden || element.style.display == "none" || boundingRect.width <= 1 && boundingRect.height <= 1) {
-							element.setAttribute(markerRemovedContent, "");
+						if (element.getBoundingClientRect) {
+							const boundingRect = element.getBoundingClientRect();
+							if (element.hidden || element.style.display == "none" || boundingRect.width <= 1 && boundingRect.height <= 1) {
+								element.setAttribute(markerRemovedContent, "");
+							}
 						}
 					});
 					elementsInfo = new Map(Array.from(elementsInfo).filter(([element]) => element.getAttribute(markerRemovedContent) != ""));
@@ -188,7 +190,7 @@ this.docHelper = this.docHelper || (() => {
 		let hidden = false;
 		if (style) {
 			hidden = style.display == "none";
-			if (!hidden && (style.opacity == "0" || style.visibility == "hidden")) {
+			if (!hidden && (style.opacity == "0" || style.visibility == "hidden") && element.getBoundingClientRect) {
 				const boundingRect = element.getBoundingClientRect();
 				hidden = !boundingRect.width && !boundingRect.height;
 			}