1
0
Эх сурвалжийг харах

remove aternate stylesheets

Gildas 7 жил өмнө
parent
commit
bdb4b5d1a0

+ 7 - 8
lib/single-file/single-file-core.js

@@ -857,24 +857,23 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		async resolveLinkedStylesheetURLs() {
 			await Promise.all(Array.from(this.doc.querySelectorAll("link[rel*=stylesheet]")).map(async linkElement => {
 				const options = { maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled, charSet: this.charSet };
-				const stylesheetContent = await DomProcessorHelper.resolveLinkStylesheetURLs(linkElement.href, this.baseURI, options);
+				let stylesheetContent = await DomProcessorHelper.resolveLinkStylesheetURLs(linkElement.href, this.baseURI, options);
 				if (stylesheetContent) {
 					const styleElement = this.doc.createElement("style");
 					if (linkElement.media) {
 						styleElement.media = linkElement.media;
 					}
-					if (linkElement.rel) {
-						styleElement.rel = linkElement.rel;
-					}
-					if (linkElement.title) {
-						styleElement.title = linkElement.title;
+					if (linkElement.rel.includes("alternate") && linkElement.title) {
+						linkElement.remove();
+					} else {
+						styleElement.textContent = stylesheetContent;
+						linkElement.parentElement.replaceChild(styleElement, linkElement);
 					}
-					styleElement.textContent = stylesheetContent;
-					linkElement.parentElement.replaceChild(styleElement, linkElement);
 				} else {
 					linkElement.remove();
 				}
 			}));
+			// debugger
 		}
 	}