aboutsummaryrefslogtreecommitdiffstats
path: root/lib/component.client.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-11-01 08:07:40 +0000
committers-ol <s-ol@users.noreply.github.com>2018-11-01 08:07:40 +0000
commit29d2b615dafa6f3a54910b72d303f74a97c4d822 (patch)
tree7ba2e8bdbb94d9704bc2065cb87de99304f92fdd /lib/component.client.moon
parentsmooth navigation (diff)
downloadmmm-29d2b615dafa6f3a54910b72d303f74a97c4d822.tar.gz
mmm-29d2b615dafa6f3a54910b72d303f74a97c4d822.zip
component get_or_create
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,