Procházet zdrojové kódy

fixed issue with embedded resources in serialized shadow dom elemnts

Gildas před 7 roky
rodič
revize
aa6261bb56
1 změnil soubory, kde provedl 7 přidání a 2 odebrání
  1. 7 2
      lib/single-file/single-file-core.js

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

@@ -663,8 +663,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 					const elementInfo = this.options.shadowRootContents[elementIndex];
 					if (DOMParser) {
 						const iframeElement = this.doc.createElement("iframe");
-						iframeElement.setAttribute("srcdoc", elementInfo.content);
 						iframeElement.setAttribute("style", "all:initial!important;border:0!important;width:100%!important;height:" + elementInfo.height + "px!important");
+						const windowId = "shadow-" + this.options.framesData.length;
+						iframeElement.setAttribute(DOM.windowIdAttributeName(this.options.sessionId), windowId);
+						this.options.framesData.push({ windowId, content: elementInfo.content, baseURI: this.baseURI });
 						element.appendChild(iframeElement);
 					}
 				});
@@ -1049,6 +1051,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				frameElement.setAttribute("data", "data:text/html,");
 			} else {
 				frameElement.removeAttribute("src");
+				frameElement.removeAttribute("srcdoc");
 			}
 		}
 
@@ -1096,7 +1099,9 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 
 		static async resolveImportURLs(stylesheetContent, baseURI, options) {
 			stylesheetContent = DomProcessorHelper.resolveStylesheetURLs(stylesheetContent, baseURI, options);
-			stylesheetContent = DomUtil.removeCssComments(stylesheetContent);
+			if (options.compressCSS) {
+				// stylesheetContent = DomUtil.removeCssComments(stylesheetContent);
+			}
 			const imports = DomUtil.getImportFunctions(stylesheetContent);
 			await Promise.all(imports.map(async cssImport => {
 				const match = DomUtil.matchImport(cssImport);