<?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>22928</bug_id>
          
          <creation_ts>2013-08-13 00:00:17 +0000</creation_ts>
          <short_desc>[Custom]: Callbacks timing and HTML Imports</short_desc>
          <delta_ts>2013-08-30 22:47:34 +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>dominicc</cc>
    
    <cc>sjmiles</cc>
    
    <cc>sorvell</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>91949</commentid>
    <comment_count>0</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-13 00:00:17 +0000</bug_when>
    <thetext>This feature is probably more relevant to custom elements than imports, so putting it into custom elements pile.

Consider this situation:

x-foo.html:
&lt;polymer-element name=&quot;x-bar&quot;&gt;
...

index.html:
&lt;script&gt; document.register(&apos;polymer-element&apos;, ...
...
&lt;link rel=import href=&quot;x-foo.html&quot;&gt;
...
&lt;x-foo&gt;&lt;/x-foo&gt;

The desired created callback order here is:

polymer-element
x-foo

However, since imports are loaded asynchronously, it&apos;s pretty likely that the order will actually be:

x-foo
polymer-element

... which will result in sadness (polymer-element registers x-foo).

It smells like we need some sort of extra-ordering to callbacks for imports?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92583</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-26 16:50:11 +0000</bug_when>
    <thetext>*** Bug 23069 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92613</commentid>
    <comment_count>2</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-08-27 02:15:03 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; Consider this situation:
&gt; 
&gt; x-foo.html:
&gt; &lt;polymer-element name=&quot;x-bar&quot;&gt;
&gt; ...
&gt; 
&gt; index.html:
&gt; &lt;script&gt; document.register(&apos;polymer-element&apos;, ...
&gt; ...
&gt; &lt;link rel=import href=&quot;x-foo.html&quot;&gt;
&gt; ...
&gt; &lt;x-foo&gt;&lt;/x-foo&gt;
&gt; 
&gt; The desired created callback order here is:
&gt; 
&gt; polymer-element
&gt; x-foo
&gt; 
&gt; However, since imports are loaded asynchronously, it&apos;s pretty likely that
&gt; the order will actually be:
&gt; 
&gt; x-foo
&gt; polymer-element

How would that arise? No callbacks for x-foo happen until it is registered. If the polymer-element is the thing that registers x-foo, then the callback order must be polymer-element, x-foo.

The example on bug 23069 is more persuasive...
 
&gt; It smells like we need some sort of extra-ordering to callbacks for imports?

My gut feeling is that &lt;element&gt; was put on hiatus because of timing complexity, and we&apos;re bringing the complexity back because someone wants to wrap document.register into a declarative form. In particular, imports aren&apos;t special; wouldn&apos;t you have the same issue with async external scripts?

I think any ordering we define is going to be complex. Instead I think we should either:

A. Do nothing. &lt;polymer-element&gt; can define its own system for deferring until base definitions are available.

B. Add an event publicising when a definition is registered. Then &lt;foo-element&gt; can interoperably wait until a definition is available.

If a page needs to synchronize with imports, it should do it with &lt;script&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92765</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-30 22:47:34 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/webcomponents/rev/4bf5aad1b9cb</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>