Ver Fonte

insert script for web components initialization only when needed

Gildas há 6 anos atrás
pai
commit
3ddcf81da0
1 ficheiros alterados com 1 adições e 1 exclusões
  1. 1 1
      lib/single-file/single-file-core.js

+ 1 - 1
lib/single-file/single-file-core.js

@@ -1069,7 +1069,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			const rootDoc = this.doc;
 			const options = this.options;
 			const stats = this.stats;
-			if (this.options.shadowRootsData) {
+			if (this.options.shadowRootsData && this.options.shadowRootsData.length) {
 				await processRootElement(this.doc);
 				const scriptElement = rootDoc.createElement("script");
 				scriptElement.textContent = `processNode(document);function processNode(node){node.querySelectorAll("[${WC_ATTRIBUTE_NAME}]").forEach(element=>{const shadowRoot=element.previousElementSibling.attachShadow({mode:"open"});shadowRoot.innerHTML=element.innerHTML;element.remove();processNode(shadowRoot)})}`;