aboutsummaryrefslogtreecommitdiffstats
path: root/lib/component.client.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-11-01 09:01:49 +0000
committers-ol <s-ol@users.noreply.github.com>2018-11-01 09:01:49 +0000
commitfc181b154fb3f5cdefcf72c2a496b5b14f274e79 (patch)
tree5b4cfbebb4760fba68161265f07826b55206c311 /lib/component.client.moon
parentREHYDRATION (diff)
parentfaster time to first render (diff)
downloadmmm-fc181b154fb3f5cdefcf72c2a496b5b14f274e79.tar.gz
mmm-fc181b154fb3f5cdefcf72c2a496b5b14f274e79.zip
Merge branch 'root-mmmfs'
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,