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

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

From: Adam Barth <w3c@adambarth.com>
Date: Thu, 17 Nov 2011 16:37:59 -0800
Message-ID: <CAJE5ia9=282JuE4OeaJPYt38ddHTCE9UMTT7zTG-E4=AmCJTPw@mail.gmail.com>
On Thu, Nov 17, 2011 at 4:37 PM, Rafael Weinstein <rafaelw at chromium.org> wrote:
> On Thu, Nov 17, 2011 at 2:45 PM, Adam Barth <w3c at adambarth.com> wrote:
>> On Thu, Nov 17, 2011 at 2:22 PM, Rafael Weinstein <rafaelw at chromium.org> wrote:
>>> On Thu, Nov 17, 2011 at 12:50 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote:
>>>> On Thu, Nov 17, 2011 at 11:15 AM, Rafael Weinstein <rafaelw at chromium.org> wrote:
>>>>> Big question: by what mechanism are these elements inert?
>>>> I like Adam's suggestion of a new document without a browsing context.
>>>> ?You can still move the elements into the active document and have
>>>> them "just work", and all the other issues are taken care of "for
>>>> free".
>>> I think that would be a fine solution. When I discussed this with
>>> various folks, that option came up as well, but some were concerned
>>> that a document might too heavy weight.
>>> Keep in mind that pages may have *many* <template> declarations. I'd
>>> expect a sophisticated page/app to have template declarations the
>>> hundreds if not thousands.
>> Have you benchmarked it? ?Documents that lack browsing contexts are
>> actually pretty light. ?Most of the "weight" comes from browsing
>> context. ?As an example, we create and destroy a document every time
>> someone assigns to innerHTML.
> Nope. If the overhead of creating documents is a non-issue, then
> so-much-the-better.
> Would being a document imply <html> or <body>. I.e. would the following
> <template>Hello, World</template>
> Result in myTemplate.contentDocument being
> <html>
> ?<body>Hello, world</body>
> </html>
> ?

The most appropriate thing is probably a DocumentFragment actually.
That avoids the trickiness of the boilerplate elements.

If you like, you can get a ballpark benchmark using

Received on Thursday, 17 November 2011 16:37:59 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:37 UTC