diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-20 07:19:12 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-20 07:19:12 +0100 |
commit | 68b8e8a7fb92b49e17db201ed84b1e9d60b461dd (patch) | |
tree | 361807f726c46e7925a7f554ed2800c0f9424d58 | |
parent | 154398b2e68274c52d2496383696132aafcd901b (diff) | |
download | lustre-68b8e8a7fb92b49e17db201ed84b1e9d60b461dd.tar.gz lustre-68b8e8a7fb92b49e17db201ed84b1e9d60b461dd.zip |
:bug: Fixed bug where starting passing in an existing element to App.start was not handled properly.
-rw-r--r-- | lib/src/lustre.ffi.mjs | 8 |
1 files changed, 5 insertions, 3 deletions
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; |