From: Ardis Lu Date: Tue, 8 Jul 2025 02:17:17 +0000 (-0700) Subject: Move instantiation logic to `connectedCallback` X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=17956776738bb9c47778441856a42daa3fff58e6;p=utf-8-visualizer Move instantiation logic to `connectedCallback` Reference: https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-conformance --- diff --git a/script.js b/script.js index 2393fe4..164b3c0 100644 --- a/script.js +++ b/script.js @@ -4,8 +4,7 @@ const invisibleCharacters = [9, 10, 11, 12, 13, 32, 127, 160, 173, 847, 1564, 44 const encoder = new TextEncoder(); customElements.define('al-point-visualization', class extends HTMLElement { - constructor() { - super(); + connectedCallback() { const template = document.querySelector('template').content; const shadowRoot = this.attachShadow({ mode: 'open' }); shadowRoot.appendChild(template.cloneNode(true));