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

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

Closes #6289