Explorar el Código

remove style element if sheet is not defined

Gildas hace 7 años
padre
commit
3b27447e33
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  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();
+				}
 			}));
 		}