diff options
Diffstat (limited to 'lib/component.server.moon')
| -rw-r--r-- | lib/component.server.moon | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/component.server.moon b/lib/component.server.moon index d717ff7..0026d32 100644 --- a/lib/component.server.moon +++ b/lib/component.server.moon @@ -1,5 +1,8 @@ import opairs from require 'lib.ordered' +void_tags = { 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr' } +void_tags = { t,t for t in *void_tags } + -- convert anything to HTML string -- val must be one of: -- * MMMElement (have a .render method that returns a string) @@ -97,9 +100,15 @@ class ReactiveElement tmp ..= "#{kk}: #{vv}; " v = tmp b ..= " #{k}=\"#{v}\"" - b ..= ">" .. table.concat @children, '' - b ..= "</#{@element}>" - b + + if void_tags[@element] + assert #@children == 0, "void tag #{element} cannot have children!" + b .. ">" + else + b .. ">" + b ..= ">" .. table.concat @children, '' + b ..= "</#{@element}>" + b elements = setmetatable {}, __index: (name) => with val = (...) -> ReactiveElement name, ... |
