W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2011

[whatwg] Declarative Inert DOM (e.g. the <template> element)

From: Jonas Sicking <jonas@sicking.cc>
Date: Fri, 18 Nov 2011 13:33:53 -0800
Message-ID: <CA+c2ei9uYUjCmLX5U9n+3ku98VBG7EPLj_og2kht3A3jg499Uw@mail.gmail.com>
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
> HTMLTemplateElement.

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.

/ Jonas
Received on Friday, 18 November 2011 13:33:53 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:09 UTC