Kaynağa Gözat

insert script for web components initialization only when needed

Gildas 6 yıl önce
ebeveyn
işleme
3ddcf81da0
1 değiştirilmiş dosya ile 1 ekleme ve 1 silme
  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)})}`;