diff options
Diffstat (limited to 'site/game.mjs')
| -rw-r--r-- | site/game.mjs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/site/game.mjs b/site/game.mjs index 0fb5974..26c2370 100644 --- a/site/game.mjs +++ b/site/game.mjs @@ -64,13 +64,9 @@ export default class extends HTMLElement { robo.worker.onmessage = msg => this.#messageHandler(i, msg); robo.worker.onerror = msg => this.#errorHander(i, msg); - // the only reliable way i have of talking to the element - // that's attached is to append the template, then fetch that - // out of the dom. neither cloneNode(true|false) nor - // document.importNode(true|false) worked to fire the event - // listener if attached before adding it to the dom. - this.#inspectorsSection.appendChild(this.#inspectorTemplate.content.cloneNode(true)); - const inspector = this.#inspectorsSection.children[this.#inspectorsSection.children.length-1]; + const cloned = document.importNode(this.#inspectorTemplate.content, true); + const inspector = cloned.children.item(0); + this.#inspectorsSection.appendChild(inspector); inspector.addEventListener(Inspector.compileRequest, e => { console.debug('compiling for worker', e.detail.text, robo.worker); robo.worker.postMessage({ kind: 'compile', text: e.detail.text }); |
