|
|
@@ -745,7 +745,11 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
async resolveStylesheetURLs() {
|
|
|
await Promise.all(Array.from(this.doc.querySelectorAll("style, link[rel*=stylesheet]"))
|
|
|
.map(async element => {
|
|
|
- this.stylesheets.set(element, { media: element.media });
|
|
|
+ let mediaText;
|
|
|
+ if (element.media) {
|
|
|
+ mediaText = element.media;
|
|
|
+ }
|
|
|
+ this.stylesheets.set(element, { mediaText });
|
|
|
const options = { maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled, url: this.options.url, charSet: this.charSet, compressCSS: this.options.compressCSS };
|
|
|
const isLinkTag = element.tagName.toLowerCase() == "link";
|
|
|
if (isLinkTag && element.rel.includes("alternate") && element.title) {
|
|
|
@@ -790,8 +794,8 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
stylesheetContent = DOM.compressCSS(stylesheetContent);
|
|
|
}
|
|
|
styleElement.textContent = stylesheetContent;
|
|
|
- if (stylesheetInfo.media) {
|
|
|
- styleElement.media = stylesheetInfo.media;
|
|
|
+ if (stylesheetInfo.mediaText) {
|
|
|
+ styleElement.media = stylesheetInfo.mediaText;
|
|
|
}
|
|
|
} else {
|
|
|
styleElement.remove();
|
|
|
@@ -801,8 +805,8 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const stylesheetInfo = this.stylesheets.get(linkElement);
|
|
|
if (stylesheetInfo) {
|
|
|
const styleElement = this.doc.createElement("style");
|
|
|
- if (stylesheetInfo.media) {
|
|
|
- styleElement.media = stylesheetInfo.media;
|
|
|
+ if (stylesheetInfo.mediaText) {
|
|
|
+ styleElement.media = stylesheetInfo.mediaText;
|
|
|
}
|
|
|
let stylesheetContent = cssTree.generate(stylesheetInfo.stylesheet);
|
|
|
if (this.options.compressCSS) {
|