diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-07-01 23:09:37 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-07-01 23:09:37 +0000 |
| commit | d6fd0bf7834a284b61e7275ebb07b718458f075b (patch) | |
| tree | 06db4faf87cd2a6019b3e660146a979aac02c954 /app/component.moon | |
| parent | update packages (diff) | |
| download | mmm-d6fd0bf7834a284b61e7275ebb07b718458f075b.tar.gz mmm-d6fd0bf7834a284b61e7275ebb07b718458f075b.zip | |
export asnode, append helpers
Diffstat (limited to 'app/component.moon')
| -rw-r--r-- | app/component.moon | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/app/component.moon b/app/component.moon index 86458bd..f0bc77f 100644 --- a/app/component.moon +++ b/app/component.moon @@ -18,6 +18,13 @@ asnode = (val) -> else error "not a Node: #{val}, #{type val}" +-- shorthand to append elements to body +-- see #asnode for permitted values +append = (val) -> document.body\appendChild asnode val + +-- shorthand to form a text node from strings +text = (...) -> document\createTextNode table.concat { ... }, ' ' + class ReactiveVar @isinstance: (val) -> 'table' == (type val) and val.subscribe @@ -102,15 +109,15 @@ class ReactiveElement if 'table' == (type child) and child.destroy child\destroy! -text = (...) -> document\createTextNode table.concat { ... }, ' ' - with exports = { :ReactiveVar, :ReactiveElement, + :asnode, + :append, :text, } add = (e) -> exports[e] = (...) -> ReactiveElement e, ... - for e in *{'div', 'form', 'span', 'a', 'p', 'button', 'ul', 'li', 'i', 'b', 'u', 'tt'} do add e + for e in *{'div', 'form', 'span', 'article', 'a', 'p', 'button', 'ul', 'li', 'i', 'b', 'u', 'tt'} do add e for e in *{'br', 'img', 'input', 'p', 'textarea'} do add e for i=1,8 do add "h" .. i |
