Parcourir la source

remove style element if sheet is not defined

Gildas il y a 7 ans
Parent
commit
3b27447e33
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  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();
+				}
 			}));
 		}