Jelajahi Sumber

ignore "Accessing from Xray wrapper..." errors

Gildas 3 tahun lalu
induk
melakukan
38e1c97445
1 mengubah file dengan 11 tambahan dan 3 penghapusan
  1. 11 3
      src/single-file/single-file-helper.js

+ 11 - 3
src/single-file/single-file-helper.js

@@ -141,7 +141,11 @@ function preProcessDoc(doc, win, options) {
 			invalidElements.set(element, placeHolderElement);
 			element.replaceWith(placeHolderElement);
 		});
-		elementsInfo = getElementsInfo(win, doc, doc.documentElement, options);
+		try {
+			elementsInfo = getElementsInfo(win, doc, doc.documentElement, options);
+		} catch (error) {
+			debugger;
+		}
 		if (options.moveStylesInHead) {
 			doc.querySelectorAll("body style, body ~ style").forEach(element => {
 				const computedStyle = win.getComputedStyle(element);
@@ -224,8 +228,12 @@ function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map
 			shadowRootInfo.content = shadowRoot.innerHTML;
 			shadowRootInfo.delegatesFocus = shadowRoot.delegatesFocus;
 			shadowRootInfo.mode = shadowRoot.mode;
-			if (shadowRoot.adoptedStyleSheets && shadowRoot.adoptedStyleSheets.length) {
-				shadowRootInfo.adoptedStyleSheets = Array.from(shadowRoot.adoptedStyleSheets).map(stylesheet => Array.from(stylesheet.cssRules).map(cssRule => cssRule.cssText).join("\n"));
+			try {
+				if (shadowRoot.adoptedStyleSheets && shadowRoot.adoptedStyleSheets.length) {
+					shadowRootInfo.adoptedStyleSheets = Array.from(shadowRoot.adoptedStyleSheets).map(stylesheet => Array.from(stylesheet.cssRules).map(cssRule => cssRule.cssText).join("\n"));
+				}
+			} catch (error) {
+				// ignored
 			}
 		}
 		getElementsInfo(win, doc, element, options, data, elementHidden);