1class Strudel extends HTMLElement { 2 constructor() { 3 super(); 4 } 5 connectedCallback() { 6 setTimeout(() => { 7 const code = this.getAttribute('code') || (this.innerHTML + '').replace('<!--', '').replace('-->', '').trim(); 8 const iframe = document.createElement('iframe'); 9 const src = `https://strudel.cc/#${encodeURIComponent(btoa(code))}`; 10 // const src = `http://localhost:3000/#${encodeURIComponent(btoa(code))}`; 11 iframe.setAttribute('src', src); 12 iframe.setAttribute('width', '600'); 13 iframe.setAttribute('height', '400'); 14 this.appendChild(iframe); 15 }); 16 } 17} 18customElements.define('strudel-repl', Strudel);