|
|
@@ -790,9 +790,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const stylesheetInfo = this.stylesheets.get(styleElement);
|
|
|
if (stylesheetInfo) {
|
|
|
let stylesheetContent = cssTree.generate(stylesheetInfo.stylesheet);
|
|
|
- if (this.options.compressCSS) {
|
|
|
- stylesheetContent = DOM.compressCSS(stylesheetContent);
|
|
|
- }
|
|
|
styleElement.textContent = stylesheetContent;
|
|
|
if (stylesheetInfo.mediaText) {
|
|
|
styleElement.media = stylesheetInfo.mediaText;
|
|
|
@@ -809,9 +806,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
styleElement.media = stylesheetInfo.mediaText;
|
|
|
}
|
|
|
let stylesheetContent = cssTree.generate(stylesheetInfo.stylesheet);
|
|
|
- if (this.options.compressCSS) {
|
|
|
- stylesheetContent = DOM.compressCSS(stylesheetContent);
|
|
|
- }
|
|
|
styleElement.textContent = stylesheetContent;
|
|
|
linkElement.parentElement.replaceChild(styleElement, linkElement);
|
|
|
} else {
|
|
|
@@ -959,15 +953,19 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
|
|
|
resolveStyleAttributeURLs() {
|
|
|
Array.from(this.doc.querySelectorAll("[style]")).map(element => {
|
|
|
- element.setAttribute("style", DomProcessorHelper.resolveStylesheetURLs(element.getAttribute("style"), this.baseURI, this.options));
|
|
|
- const declarationList = cssTree.parse(element.getAttribute("style"), { context: "declarationList" });
|
|
|
+ let styleContent = element.getAttribute("style");
|
|
|
+ if (this.options.compressCSS) {
|
|
|
+ styleContent = DOM.compressCSS(styleContent);
|
|
|
+ }
|
|
|
+ styleContent = DomProcessorHelper.resolveStylesheetURLs(styleContent, this.baseURI, this.options);
|
|
|
+ const declarationList = cssTree.parse(styleContent, { context: "declarationList" });
|
|
|
this.styles.set(element, declarationList);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
async processStyleAttributes() {
|
|
|
- await Promise.all(Array.from(this.doc.querySelectorAll("[style]")).map(async element => {
|
|
|
- await DomProcessorHelper.processStyle(this.styles.get(element).children.toArray(), this.baseURI, this.options, this.cssVariables, this.batchRequest);
|
|
|
+ return Promise.all(Array.from(this.styles).map(([, declarationList]) => {
|
|
|
+ return DomProcessorHelper.processStyle(declarationList.children.toArray(), this.baseURI, this.options, this.cssVariables, this.batchRequest);
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
@@ -976,9 +974,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const declarations = this.styles.get(element);
|
|
|
if (declarations) {
|
|
|
let styleContent = cssTree.generate(declarations);
|
|
|
- if (this.options.compressCSS) {
|
|
|
- styleContent = DOM.compressCSS(styleContent);
|
|
|
- }
|
|
|
element.setAttribute("style", styleContent);
|
|
|
} else {
|
|
|
element.setAttribute("style", "");
|
|
|
@@ -1128,7 +1123,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, validateTextContentType: true };
|
|
|
let importedStylesheetContent = await Download.getContent(resourceURL, downloadOptions);
|
|
|
if (options.compressCSS) {
|
|
|
- importedStylesheetContent = DomUtil.removeCssComments(importedStylesheetContent);
|
|
|
+ importedStylesheetContent = DOM.compressCSS(DomUtil.removeCssComments(importedStylesheetContent));
|
|
|
}
|
|
|
importedStylesheetContent = DomUtil.wrapMediaQuery(importedStylesheetContent, match.media);
|
|
|
if (stylesheetContent.includes(cssImport)) {
|
|
|
@@ -1173,7 +1168,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
let stylesheetContent = await Download.getContent(resourceURL, downloadOptions);
|
|
|
stylesheetContent = await DomProcessorHelper.resolveImportURLs(stylesheetContent, resourceURL, options);
|
|
|
if (options.compressCSS) {
|
|
|
- stylesheetContent = DomUtil.removeCssComments(stylesheetContent);
|
|
|
+ stylesheetContent = DOM.compressCSS(DomUtil.removeCssComments(stylesheetContent));
|
|
|
}
|
|
|
return stylesheetContent;
|
|
|
}
|