The template is of a tr element. So intuitively, one would think "if I want to insert my tr template before another tr, I would pass in that specific tr as the element to the insertBefore function". This yields a wicked bug in the insertHtml function of the DomHelper class:

As you know, the insertIntoTable function is called by the insertHtml function because the passed element has the tr tagName. In the code above, you see that if the tagName is NOT table or tbody, then this code runs:

Ok, so this makes it so our tr template gets put into a tbody in your tempTableEl code in the insertIntoTable function. Good. But this still isn't good, because the insertBefore function uses the 'beforebegin' where clause, which runs this code:

Not good. Our tr is being put into the table before the tbody element. Well ! We're close though. Here was the final fix, going straight through to the DomHelper since there was no wrapper for the 'afterbegin' where clause: