chaplinjs/chaplin

itemView with nowrap=true doesn't work when template produces TR

npoppeli opened this issue · 1 comments

When you have an itemView with option nowrap=true and a template that produces a single TR element (with lots of things inside the TR), Chaplin raises an error in line 432 of view.coffee. Try this for demonstration:

$ ->
  html = """<tr><td>text1</td><td>text2</td>
            <td><button id='id1'><span class='fa fa-pencil'></span></button></td>
            <td><button id='id2'><span class='fa fa-pencil'></span></button></td>
          </tr>"""
  el = document.createElement 'div'
  el.innerHTML = html
  for child, l in el.children
    console.log "child #{l}: #{child.tagName} id=#{child.id}"

There are two elements in el.children, namely the two buttons. Appararently the innerHTML() method discards the TR and TD nodes (tested on Chromium 48.0 and Firefox 44.0). I don't know if this should be fixed in the code, or clarified in the documentation.

Could an alternative be:
parser = new DOMParser()
el = parser.parseFromString(html, 'text/xml')`