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

<CAJE5ia9=282JuE4OeaJPYt38ddHTCE9UMTT7zTG-E4=AmCJTPw@mail.gmail.com>

Current votes: None.

On Thu, Nov 17, 2011 at 4:37 PM, Rafael Weinstein <rafaelw@chromium.org> wr=
ote:
> On Thu, Nov 17, 2011 at 2:45 PM, Adam Barth <w3c@adambarth.com> wrote:
>> On Thu, Nov 17, 2011 at 2:22 PM, Rafael Weinstein <rafaelw@chromium.org>=
 wrote:
>>> On Thu, Nov 17, 2011 at 12:50 PM, Tab Atkins Jr. <jackalmage@gmail.com>=
 wrote:
>>>> On Thu, Nov 17, 2011 at 11:15 AM, Rafael Weinstein <rafaelw@chromium.o=
rg> wrote:
>>>>> Big question: by what mechanism are these elements inert?
>>>>
>>>> I like Adam's suggestion of a new document without a browsing context.
>>>> =A0You 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? =A0Documents that lack browsing contexts are
>> actually pretty light. =A0Most of the "weight" comes from browsing
>> context. =A0As 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>
> =A0<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
document.createDocumentFragment.

Adam