From 00f258dc7a305fe683d473aa6c6e526fa0b68d9c Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sun, 20 Aug 2023 07:20:49 +0100 Subject: :sparkles: Add a util for checking if a component name has already been registered. --- lib/src/lustre.ffi.mjs | 1 + lib/src/lustre.gleam | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/src/lustre.ffi.mjs b/lib/src/lustre.ffi.mjs index b0f4661..10524e0 100644 --- a/lib/src/lustre.ffi.mjs +++ b/lib/src/lustre.ffi.mjs @@ -216,3 +216,4 @@ export const setup_component = ( // UTLS ------------------------------------------------------------------------ export const is_browser = () => window && window.document; +export const is_registered = (name) => !!customElements.get(name); diff --git a/lib/src/lustre.gleam b/lib/src/lustre.gleam index ec04f3e..2585a5b 100644 --- a/lib/src/lustre.gleam +++ b/lib/src/lustre.gleam @@ -253,3 +253,8 @@ pub fn start( pub fn is_browser() -> Bool { False } + +@external(javascript, "./lustre.ffi.mjs", "is_registered") +pub fn is_registered(_name: String) -> Bool { + False +} -- cgit v1.2.3