From 68b8e8a7fb92b49e17db201ed84b1e9d60b461dd Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sun, 20 Aug 2023 07:19:12 +0100 Subject: :bug: Fixed bug where starting passing in an existing element to App.start was not handled properly. --- lib/src/lustre.ffi.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/src/lustre.ffi.mjs') diff --git a/lib/src/lustre.ffi.mjs b/lib/src/lustre.ffi.mjs index c7008ed..9181fd5 100644 --- a/lib/src/lustre.ffi.mjs +++ b/lib/src/lustre.ffi.mjs @@ -35,13 +35,15 @@ export class App { if (!is_browser()) return new Error(new NotABrowser()); if (this.#root) return new Error(new AppAlreadyStarted()); - const el = document.querySelector(selector); + this.$root = + selector instanceof HTMLElement + ? selector + : document.querySelector(selector); - if (!el) return new Error(new ElementNotFound()); + if (!this.$root) 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; -- cgit v1.2.3