[whatwg] Declarative Inert DOM (e.g. the <template> element)
jonas at sicking.cc
Fri Nov 18 13:33:53 PST 2011
On Thu, Nov 17, 2011 at 11:21 AM, Adam Barth <w3c at adambarth.com> wrote:
> Another option is to tokenize the elements as usual, but put them into
> a new document created for the <template> element (presumably using
> the usual tree-building rules). Because this document won't have a
> browsing context, all the elements would be "inert", like they are for
> documents created by XMLHttpRequest. The site could access this
> document via a templateDocument (or whatever) property on
What is the advantage of this approach?
Not being able to interact with the template normally seems like a
pretty big downside for templating systems as you completely lose the
ability to use the normal flow of interacting with your DOM if you
want to modify the template for future instances. I.e. you can't
simply use .getElementById to find an element inside the template in
order to interact with it.
Implementation-wise I think making "normal" elements inert would be
easier since you can keep all existing DOM and parsing infrastructure.
All you need to do is to propagate an internal "isInert" flag any time
an element is inserted into the DOM. Then pay attention to this flag
in the situations where the spec says that inert elements behave
differently from normal elements.
More information about the whatwg