fix($compile): support templates with thead and tfoot root elements

If the first element in a template is a <thead> or a <tfoot>, then
using the existing logic to handle table elements compilation.

Closes #6289