diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-10-30 08:00:19 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-10-30 08:11:45 +0000 |
| commit | fa79588be9c10edac27427dd2530b098abce3fea (patch) | |
| tree | 7ada333f2468df8dab6e956f3000da3bb1703192 /lib/component.client.moon | |
| parent | fix inline code (diff) | |
| download | mmm-fa79588be9c10edac27427dd2530b098abce3fea.tar.gz mmm-fa79588be9c10edac27427dd2530b098abce3fea.zip | |
REHYDRATION
Diffstat (limited to 'lib/component.client.moon')
| -rw-r--r-- | lib/component.client.moon | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/component.client.moon b/lib/component.client.moon index 7357f50..6e0e8d8 100644 --- a/lib/component.client.moon +++ b/lib/component.client.moon @@ -65,7 +65,10 @@ class ReactiveElement @isinstance: (val) -> 'table' == (type val) and val.node new: (element, ...) => - @node = document\createElement element + if 'userdata' == type element + @node = element + else + @node = document\createElement element @_subscriptions = {} children = { ... } @@ -105,7 +108,8 @@ class ReactiveElement @node[attr] = value - append: (child, last) => + prepend: (child, last) => @append child, last, 'prepend' + append: (child, last, mode='append') => if ReactiveVar.isinstance child table.insert @_subscriptions, child\subscribe (...) -> @append ... child = child\get! @@ -123,7 +127,9 @@ class ReactiveElement if ok @node\replaceChild child, last else - @node\appendChild child + switch mode + when 'append' then @node\appendChild child + when 'prepend' then @node\insertBefore child, @node.firstChild remove: (child) => @node\removeChild tohtml child |
