jadelet
jadelet copied to clipboard
Automatically add missing root element
Would it be wrong if the missing root element is automatically added:
So
.one
.two
becomes
div
.one
.two
I did a test with a small change in the compiler.coffee, and it works.
compile = (parseTree, {compiler, runtime, exports}={}) ->
if parseTree.length > 1
parseTree = [{tag: "div", children: parseTree}]
The only caveat here is that the HTML output might not be what the user expects.
It may be possible to wrap the items in a documentFragment. This should be fine for the external uses as document.body.appendChild will work fine with that, but we may need to add a check for when a template adds a subtemplate to get the reference counts right in the Jadelet runtime.
It is better form to have each template have a designated root element, semantically it just makes more sense to me. Personally I've never needed sibling elements returned in practice.