Explorar o código

added IIFE around the script used to attach shadow root contents

Gildas %!s(int64=6) %!d(string=hai) anos
pai
achega
4411ffa82e
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      lib/single-file/single-file-core.js

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

@@ -1072,7 +1072,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 			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.parentElement.attachShadow({mode:"open"});shadowRoot.innerHTML=element.innerHTML;element.remove();processNode(shadowRoot)})}`;
+				scriptElement.textContent = `(()=>{processNode(document);function processNode(node){node.querySelectorAll("[${WC_ATTRIBUTE_NAME}]").forEach(element=>{const shadowRoot=element.parentElement.attachShadow({mode:"open"});shadowRoot.innerHTML=element.innerHTML;element.remove();processNode(shadowRoot)})}})()`;
 				this.doc.body.appendChild(scriptElement);
 			}