Przeglądaj źródła

ignore errors when trying to retrieve CSS content from CSSOM

Gildas 7 lat temu
rodzic
commit
ba83cdef80
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      lib/single-file/doc-helper.js

+ 6 - 2
lib/single-file/doc-helper.js

@@ -109,8 +109,12 @@ this.docHelper = this.docHelper || (() => {
 	function getStylesheetContents(doc) {
 		if (doc) {
 			const textData = [];
-			doc.querySelectorAll("style").forEach(styleElement => textData.push(Array.from(styleElement.sheet.cssRules).map(rule => rule.cssText).join("\n")));
-			return textData;
+			try {
+				doc.querySelectorAll("style").forEach(styleElement => textData.push(Array.from(styleElement.sheet.cssRules).map(rule => rule.cssText).join("\n")));
+				return textData;
+			} catch (error) {
+				/* ignored */
+			}
 		}
 	}