<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>23839</bug_id>
          
          <creation_ts>2013-11-15 19:59:46 +0000</creation_ts>
          <short_desc>[Custom]: Template document should not share registry with its document</short_desc>
          <delta_ts>2014-05-09 19:44:35 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>14968</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Dimitri Glazkov">dglazkov</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>adamk</cc>
    
    <cc>dominicc</cc>
    
    <cc>mrbkap</cc>
    
    <cc>sjmiles</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>96380</commentid>
    <comment_count>0</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-11-15 19:59:46 +0000</bug_when>
    <thetext>This was brought up by the Polymer team. In their custom elements, they have to special-case custom element being in a template and short-circuit their &quot;created&quot; callbacks to provide impression of &quot;inertness&quot;.

Also brought up here: http://techblog.ironfroggy.com/2013/11/5-reasons-web-components-arent-ready.html (see missing item 3).

This seems like a common pattern, and it&apos;s easily rectified by removing the line in spec where we share the registry with the template document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96381</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-11-15 20:01:08 +0000</bug_when>
    <thetext>The effect of this change would be that the elements are never upgraded or have their callbacks fired while in templates.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96477</commentid>
    <comment_count>2</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-11-18 23:54:10 +0000</bug_when>
    <thetext>Two questions:

1. The link mentions in Comment 1 mentions initializers running in templates; this proposal is to not share a registration context at all and hence not run any callbacks. Is not doing any prototype swizzling/callbacks just the logical consequence of not running the initializer?

2. If the registration context is not shared, does the template document get a blank registration context (&apos;register&apos; will work when used on a template document) or not? (&apos;register&apos; will throw when used on a template document.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96478</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-11-18 23:59:56 +0000</bug_when>
    <thetext>(In reply to Dominic Cooney from comment #2)
&gt; Two questions:
&gt; 
&gt; 1. The link mentions in Comment 1 mentions initializers running in
&gt; templates; this proposal is to not share a registration context at all and
&gt; hence not run any callbacks. Is not doing any prototype swizzling/callbacks
&gt; just the logical consequence of not running the initializer?

Right.

&gt; 2. If the registration context is not shared, does the template document get
&gt; a blank registration context (&apos;register&apos; will work when used on a template
&gt; document) or not? (&apos;register&apos; will throw when used on a template document.)

Just a blank registration context. Technically, it&apos;s not blank. When we spec the Registry object API, we&apos;ll say that at the time of creating a template document, we pour all of the built-in HTML element definitions into this context (just like with a Document created with XHR). The authors should be able to do the same type of sharing with their elements using that API.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96522</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-11-19 17:50:02 +0000</bug_when>
    <thetext>https://github.com/w3c/webcomponents/commit/1d4c8e006a7b07c1f5ad36ed029505b37d41423f</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96609</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2013-11-20 22:50:34 +0000</bug_when>
    <thetext>As currently specced in HTML, &lt;template&gt; doesn&apos;t always create a new Document for its content fragment; if its ownerDocument lacks a defaultView, it assumes it&apos;s fine to re-use that one. This handles the case:

&lt;template&gt;
  &lt;template&gt;
    ...

so that each &lt;template&gt; doesn&apos;t cause the creation of a new Document. However, with this spec change, it&apos;s now possible to see different Custom Element behavior in a &lt;template&gt; that happens to be in a Document created via document.implementation.createHTMLDocument(), since:

doc = document.implementation.createHTMLDocument(&apos;title&apos;)
template = doc.createElement(&apos;template&apos;)
template.ownerDocument === template.content.ownerDocument

In such documents, custom elements inside templates will be &quot;alive&quot;. The right fix is likely to tighten &lt;template&gt;&apos;s requirements for when it will re-use its ownerDocument, i.e., only re-use ownerDocument if it&apos;s actually the content owner document of another &lt;template&gt;. This requires tagging template content documents upon creation.

I intend to file the above against the HTML spec, but I wanted to have an explanation written down here, too, since it was this bug report that requires the change to &lt;template&gt;&apos;s behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101067</commentid>
    <comment_count>6</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2014-02-20 23:30:29 +0000</bug_when>
    <thetext>I think that change might have gone too far, now template documents don&apos;t have a registry at all. I think they should have a registry, but it should not be shared with the main document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105482</commentid>
    <comment_count>7</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2014-05-08 21:02:32 +0000</bug_when>
    <thetext>(In reply to Dominic Cooney from comment #6)
&gt; I think that change might have gone too far, now template documents don&apos;t
&gt; have a registry at all. I think they should have a registry, but it should
&gt; not be shared with the main document.

PTAL? https://github.com/dglazkov/webcomponents/pull/1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105566</commentid>
    <comment_count>8</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2014-05-09 19:44:35 +0000</bug_when>
    <thetext>https://github.com/dglazkov/webcomponents/commit/7476e1ce7d9e711375c7e8c12ece19518d2e958a</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>