diff options
-rw-r--r-- | lib/src/lustre.ffi.mjs | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/src/lustre.ffi.mjs b/lib/src/lustre.ffi.mjs index 5cf5058..2d07394 100644 --- a/lib/src/lustre.ffi.mjs +++ b/lib/src/lustre.ffi.mjs @@ -33,24 +33,20 @@ export class App { if (!is_browser()) return new Error(new NotABrowser()); if (this.#root) return this; - try { - const el = - selector instanceof HTMLElement - ? selector - : document.querySelector(selector); - const [next, effects] = this.#init(flags); - - this.#root = el; - this.#state = next; - this.#effects = effects[0].toArray(); - this.#didUpdate = true; + const el = document.querySelector(selector); - window.requestAnimationFrame(() => this.#tick()); + if (!el) return new Error(new ElementNotFound()); - return new Ok((msg) => this.dispatch(msg)); - } catch (_) { - return new Error(new ElementNotFound()); - } + const [next, effects] = this.#init(flags); + + this.#root = el; + this.#state = next; + this.#effects = effects[0].toArray(); + this.#didUpdate = true; + + window.requestAnimationFrame(() => this.#tick()); + + return new Ok((msg) => this.dispatch(msg)); } dispatch(msg) { |