ソースを参照

catch errors within the iteration on style elements

Gildas 7 年 前
コミット
dd2367a6ee
1 ファイル変更9 行追加7 行削除
  1. 9 7
      lib/single-file/doc-helper.js

+ 9 - 7
lib/single-file/doc-helper.js

@@ -108,13 +108,15 @@ this.docHelper = this.docHelper || (() => {
 
 	function getStylesheetContents(doc) {
 		if (doc) {
-			const 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 */
-			}
+			const contents = [];
+			doc.querySelectorAll("style").forEach(styleElement => {
+				try {
+					contents.push(Array.from(styleElement.sheet.cssRules).map(rule => rule.cssText).join("\n"));
+				} catch (error) {
+					/* ignored */
+				}
+			});
+			return contents;
 		}
 	}