diff options
-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; |