Allow the caller to provide a template for the internal DOM.

Previously we tried to keep the internal DOM hidden, but too many apps
assume that they can access the DOM directly and do funky stuff, so we'll
go with the flow and make the document actually the root element.