aboutsummaryrefslogtreecommitdiffstats
path: root/lib/component.client.moon
diff options
context:
space:
mode:
Diffstat (limited to 'lib/component.client.moon')
-rw-r--r--lib/component.client.moon7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/component.client.moon b/lib/component.client.moon
index 6e0e8d8..ffeb084 100644
--- a/lib/component.client.moon
+++ b/lib/component.client.moon
@@ -136,6 +136,12 @@ class ReactiveElement
if 'table' == (type child) and child.destroy
child\destroy!
+get_or_create = (elem, id, ...) ->
+ elem = (document\getElementById id) or elem
+
+ with ReactiveElement elem, ...
+ \set 'id', id
+
elements = setmetatable {}, __index: (name) =>
with val = (...) -> ReactiveElement name, ...
@[name] = val
@@ -143,6 +149,7 @@ elements = setmetatable {}, __index: (name) =>
{
:ReactiveVar,
:ReactiveElement,
+ :get_or_create,
-- :join,
:tohtml,
:append,