|
|
@@ -849,14 +849,18 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
charset: this.charset,
|
|
|
compressCSS: this.options.compressCSS
|
|
|
};
|
|
|
- let stylesheetContent;
|
|
|
if (element.tagName.toLowerCase() == "link") {
|
|
|
if (element.charset) {
|
|
|
options.charset = element.charset;
|
|
|
}
|
|
|
- stylesheetContent = await ProcessorHelper.resolveLinkStylesheetURLs(element.href, this.baseURI, options, this.workStyleElement);
|
|
|
- } else {
|
|
|
- stylesheetContent = await ProcessorHelper.resolveImportURLs(element.textContent, this.baseURI, options, this.workStyleElement);
|
|
|
+ }
|
|
|
+ let stylesheetContent = await getStylesheetContent(element, this.baseURI, options, this.workStyleElement);
|
|
|
+ const match = stylesheetContent.match(/^@charset\s+"([^"]*)";/i);
|
|
|
+ if (match && match[1] && match[1] != options.charset) {
|
|
|
+ if (match && match[1] && match[1] != options.charset) {
|
|
|
+ options.charset = match[1];
|
|
|
+ stylesheetContent = await getStylesheetContent(element, this.baseURI, options, this.workStyleElement);
|
|
|
+ }
|
|
|
}
|
|
|
let stylesheet;
|
|
|
try {
|
|
|
@@ -873,6 +877,14 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
this.stylesheets.delete(element);
|
|
|
}
|
|
|
}));
|
|
|
+
|
|
|
+ async function getStylesheetContent(element, baseURI, options, workStyleElement) {
|
|
|
+ if (element.tagName.toLowerCase() == "link") {
|
|
|
+ return ProcessorHelper.resolveLinkStylesheetURLs(element.href, baseURI, options, workStyleElement);
|
|
|
+ } else {
|
|
|
+ return ProcessorHelper.resolveImportURLs(element.textContent, baseURI, options, workStyleElement);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async resolveFrameURLs() {
|