jadelet icon indicating copy to clipboard operation
jadelet copied to clipboard

Automatically add missing root element

Open zdenko opened this issue 7 years ago • 1 comments

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.

zdenko avatar Feb 25 '18 17:02 zdenko

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.

STRd6 avatar Jul 03 '19 23:07 STRd6