kopia lustrzana https://github.com/shoelace-style/shoelace
Add module support to code blocks
rodzic
995744c8ef
commit
8da5ae70e3
|
@ -7,13 +7,14 @@
|
|||
|
||||
function runScript(script) {
|
||||
const newScript = document.createElement('script');
|
||||
newScript.appendChild(
|
||||
document.createTextNode(`
|
||||
(() => {
|
||||
${script.innerHTML}
|
||||
})();
|
||||
`)
|
||||
);
|
||||
|
||||
if (script.type === 'module') {
|
||||
newScript.type = 'module';
|
||||
newScript.textContent = script.innerHTML;
|
||||
} else {
|
||||
newScript.appendChild(document.createTextNode(`(() => { ${script.innerHTML} })();`));
|
||||
}
|
||||
|
||||
script.parentNode.replaceChild(newScript, script);
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue