From c26985d780edea7028e9e0203672d3376e66b450 Mon Sep 17 00:00:00 2001 From: brian cully Date: Wed, 24 Dec 2025 14:00:27 -0500 Subject: js: auto-compile loaded source --- site/inspector.mjs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'site/inspector.mjs') diff --git a/site/inspector.mjs b/site/inspector.mjs index b500478..497af32 100644 --- a/site/inspector.mjs +++ b/site/inspector.mjs @@ -63,15 +63,7 @@ export default class extends HTMLElement { SRC_SELECTOR, ].map(this.querySelector.bind(this)); - this.#compileButton.onclick = e => { - console.debug('compile clicked', e); - - // always add a newline until i decide what to do with the parser. - const text = this.#src.textContent + '\n'; - const compileEvent = new CustomEvent(this.constructor.compileRequest, { detail: { text } }); - this.dispatchEvent(compileEvent); - } - + this.#compileButton.onclick = this.#compile.bind(this); this.#srcSelect.onchange = _ => this.#loadForth(this.#srcSelect.value); this.#loadForth(this.#srcSelect.value); } @@ -107,12 +99,21 @@ export default class extends HTMLElement { }) .then(text => { this.#src.textContent = text; + this.#compile(); }) .catch(e => { console.error(`couldn't fetch ‘${path}’`, e); }); } + #compile(e) { + console.debug('compile clicked', e); + // always add a newline until i decide what to do with the parser. + const text = this.#src.textContent + '\n'; + const compileEvent = new CustomEvent(this.constructor.compileRequest, { detail: { text } }); + this.dispatchEvent(compileEvent); + } + #renderWordlist(vm) { while (this.#wordlist.lastChild) { console.debug('removing child', this.#wordlist.lastChild) -- cgit v1.3