mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 02:59:13 +00:00
Add module support to code blocks
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user