Re: Review of the <template> spec

On Fri, Dec 14, 2012 at 2:58 PM, Jonas Sicking <jonas@sicking.cc> wrote:

> On Fri, Dec 14, 2012 at 1:32 AM, Simon Pieters <simonp@opera.com> wrote:
> > On Fri, 14 Dec 2012 00:04:20 +0100, Jonas Sicking <jonas@sicking.cc>
> wrote:
> >
> >> On Tue, Dec 11, 2012 at 5:00 AM, Henri Sivonen <hsivonen@iki.fi> wrote:
> >>>>
> >>>> 1. If DOCUMENT does not have a browsing context, Let TEMPLATE CONTENTS
> >>>> OWNER be DOCUMENT and abort these steps.
> >>>> 2. Otherwise, Let TEMPLATE CONTENTS OWNER be a new Document node that
> >>>> does not have a browsing context.
> >>>
> >>>
> >>> Is there a big win from this inconsistency? Why not always have a
> >>> separate doc as the template contents owner?
>

My goal was to *only* have one separate doc per "normal" doc. Consider the
following:

<body>
  <div id=a>
  <template id=1>
    <div id=b>
    <template id=2>
      <div id=c>
    <template>
  </template>
</body>

The "if document does not have a browsing context" part is needed by
template 2 so its contents can be owned by the same document as template
1's contents. I.e. for each document with a browsing context, there is a
single (lazily created) template contents owner which is shared by all
templates reachable from the "main" document's documentElement.

I'm open to other ways of accomplishing the same thing, but like Jonas, I'm
mainly concerned here with minimizing the number of "extra" documents which
need to be constructed to owner template contents.


> >>
> >>
> >> Or why not always use the owner document of the <template> element?
> >
> >
> > I think that would cause things like <img> elements to load.
>

Correct. Remember that we've already agreed that the mechanism for template
contents "inertness" is that the content document fragment (and all of its
descendants) are owned by a document which does not have a browsing context.


>
> True. Though I wonder if that can be solved in other ways. Should be
> relatively easy to fix in Gecko, though I don't know about other
> implementations of course.
>
> Seems unfortunate to add the wonkyness of separate owner documents
> just to overcome this hurdle.



> / Jonas
>

Received on Friday, 21 December 2012 21:31:28 UTC