瀏覽代碼

remove style element if sheet is not defined

Gildas 7 年之前
父節點
當前提交
3b27447e33
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      lib/single-file/single-file-core.js

+ 5 - 1
lib/single-file/single-file-core.js

@@ -689,7 +689,11 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		async processStylesheets() {
 			await Promise.all(Array.from(this.doc.querySelectorAll("style")).map(async styleElement => {
 				this.stats.add("processed", "stylesheets", 1);
-				styleElement.textContent = await DomProcessorHelper.processStylesheet(this.doc, styleElement.textContent, styleElement.sheet.cssRules, this.baseURI, this.options, this.batchRequest);
+				if (styleElement.sheet) {
+					styleElement.textContent = await DomProcessorHelper.processStylesheet(this.doc, styleElement.textContent, styleElement.sheet.cssRules, this.baseURI, this.options, this.batchRequest);
+				} else {
+					styleElement.remove();
+				}
 			}));
 		}