Added a fix to allow "<tr></tr>".parse() etc on JS

Table elements were being stripped out because they could not be a child
of "<div>", which is what we were passing them into.

This code (for JS only) looks for the first tag, and if it is a table element,
gives it the appropriate parent.  Not ideal, but it works.

Will need to investigate performance implications of this solution...