Explorar o código

remove stylesheet links with empty href

Former-commit-id: f0152ff54864f12ea5bf5c554823449b53a1211c
Gildas %!s(int64=6) %!d(string=hai) anos
pai
achega
1c74a2b819
Modificáronse 1 ficheiros con 5 adicións e 3 borrados
  1. 5 3
      lib/single-file/single-file-core.js

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

@@ -675,7 +675,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					element.remove();
 					element.remove();
 				}
 				}
 			});
 			});
-			this.doc.querySelectorAll("link[rel*=stylesheet][rel*=alternate][title],link[rel*=stylesheet]:not([href])").forEach(element => element.remove());
+			this.doc.querySelectorAll("link[rel*=stylesheet][rel*=alternate][title],link[rel*=stylesheet]:not([href]),link[rel*=stylesheet][href=\"\"]").forEach(element => element.remove());
 			if (this.options.compressHTML) {
 			if (this.options.compressHTML) {
 				this.doc.querySelectorAll("input[type=hidden]").forEach(element => element.remove());
 				this.doc.querySelectorAll("input[type=hidden]").forEach(element => element.remove());
 			}
 			}
@@ -877,11 +877,13 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				}));
 				}));
 
 
 			async function getStylesheetContent(element, baseURI, options, workStyleElement) {
 			async function getStylesheetContent(element, baseURI, options, workStyleElement) {
+				let content;
 				if (element.tagName.toLowerCase() == "link") {
 				if (element.tagName.toLowerCase() == "link") {
-					return ProcessorHelper.resolveLinkStylesheetURLs(element.href, baseURI, options, workStyleElement);
+					content = await ProcessorHelper.resolveLinkStylesheetURLs(element.href, baseURI, options, workStyleElement);
 				} else {
 				} else {
-					return ProcessorHelper.resolveImportURLs(element.textContent, baseURI, options, workStyleElement);
+					content = await ProcessorHelper.resolveImportURLs(element.textContent, baseURI, options, workStyleElement);
 				}
 				}
+				return content || "";
 			}
 			}
 		}
 		}