Просмотр исходного кода

move resolveStylesheetURLs calls into resolveImportURLs

Gildas 7 лет назад
Родитель
Сommit
d40bc281d7
1 измененных файлов с 2 добавлено и 4 удалено
  1. 2 4
      lib/single-file/single-file-core.js

+ 2 - 4
lib/single-file/single-file-core.js

@@ -521,7 +521,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				}
 				let stylesheetContent = styleElement.textContent;
 				if (initialization) {
-					stylesheetContent = DomProcessorHelper.resolveStylesheetURLs(stylesheetContent, this.baseURI);
 					stylesheetContent = await DomProcessorHelper.resolveImportURLs(styleElement.textContent, this.baseURI, { maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled });
 				} else {
 					stylesheetContent = await DomProcessorHelper.processStylesheet(styleElement.textContent, this.baseURI);
@@ -692,6 +691,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		}
 
 		static async resolveImportURLs(stylesheetContent, baseURI, options) {
+			stylesheetContent = DomProcessorHelper.resolveStylesheetURLs(stylesheetContent, baseURI);
 			stylesheetContent = DomUtil.removeCssComments(stylesheetContent);
 			const imports = DomUtil.getImportFunctions(stylesheetContent);
 			await Promise.all(imports.map(async cssImport => {
@@ -700,10 +700,9 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 					const resourceURL = DomUtil.normalizeURL(match.resourceURL);
 					if (resourceURL != baseURI && resourceURL != ABOUT_BLANK_URI) {
 						const styleSheetUrl = new URL(match.resourceURL, baseURI).href;
-						let importedStylesheetContent = await Download.getContent(new URL(match.resourceURL, baseURI).href, { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled });
+						let importedStylesheetContent = await Download.getContent(styleSheetUrl, { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled });
 						importedStylesheetContent = DomUtil.wrapMediaQuery(importedStylesheetContent, match.media);
 						if (stylesheetContent.indexOf(cssImport) != -1) {
-							importedStylesheetContent = DomProcessorHelper.resolveStylesheetURLs(importedStylesheetContent, styleSheetUrl);
 							importedStylesheetContent = await DomProcessorHelper.resolveImportURLs(importedStylesheetContent, styleSheetUrl, options);
 							stylesheetContent = stylesheetContent.replace(cssImport, importedStylesheetContent);
 						}
@@ -736,7 +735,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			resourceURL = DomUtil.normalizeURL(resourceURL);
 			if (resourceURL && resourceURL != baseURI && resourceURL != ABOUT_BLANK_URI) {
 				let stylesheetContent = await Download.getContent(resourceURL, { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled });
-				stylesheetContent = DomProcessorHelper.resolveStylesheetURLs(stylesheetContent, resourceURL);
 				stylesheetContent = await DomProcessorHelper.resolveImportURLs(stylesheetContent, resourceURL, options);
 				stylesheetContent = DomUtil.wrapMediaQuery(stylesheetContent, media);
 				return stylesheetContent;