<?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>22899</bug_id>
          
          <creation_ts>2013-08-08 02:27:52 +0000</creation_ts>
          <short_desc>[Custom]: Consider changing the order of custom element upgrade</short_desc>
          <delta_ts>2013-08-29 22:47:25 +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="Steve Orvell">sorvell</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>dominicc</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>91769</commentid>
    <comment_count>0</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-08-08 02:27:52 +0000</bug_when>
    <thetext>The spec says &quot;Whenever an unresolved element is created, it must be added at the front of the upgrade candidates map.&quot;

The resulting behavior for a dom tree like the following is that the createdCallbacks are called in reverse order:

  &lt;x-a&gt;     4
    &lt;x-a-1&gt; 3
  &lt;/x-a&gt;
  &lt;x-b&gt;     2
    &lt;x-b-1&gt; 1
  &lt;/x-b&gt;

This allows an element&apos;s children to be upgraded before itself. This is *desirable* since can allow a parent to act on its children in their upgraded state during its created callback.

However, it&apos;s *undesirable* for &lt;x-b&gt; (older sibling) to upgrade before &lt;x-a&gt; (younger sibling). Imagine for example, the &lt;element&gt; tag implemented as a custom element. It&apos;s logical to write the extendee html before the extendor. However, if younger sibling is upgraded first, there&apos;s a problem:

  &lt;el-ement name=&quot;x-foo&quot;&gt;... &lt;/el-ement&gt;                  2
  &lt;el-ement name=&quot;x-bar&quot; extends=&quot;x-foo&quot;&gt;... &lt;/el-ement&gt;  1

It&apos;s most important to preserve sibling order. Secondarily, ideally children go before parents. Putting those together, we get:

  &lt;x-a&gt;     2
    &lt;x-a-1&gt; 1
  &lt;/x-a&gt;
  &lt;x-b&gt;     4
    &lt;x-b-1&gt; 3
  &lt;/x-b&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91851</commentid>
    <comment_count>1</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-08-09 21:12:33 +0000</bug_when>
    <thetext>If the notion is that elements queue themselves for upgrade when their end tag is encountered, then the flow of upgrade is logically `forward` and preserves the children upgrade before parents preference:

  &lt;x-a&gt;             
    &lt;x-a-1&gt;&lt;/x-a-1&gt;  1
  &lt;/x-a&gt;             2
  &lt;x-b&gt;             
    &lt;x-b-1&gt;&lt;/x-b-1&gt;  3
  &lt;/x-b&gt;             4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91874</commentid>
    <comment_count>2</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-08-12 01:25:36 +0000</bug_when>
    <thetext>What happens if there&apos;s a script tag in there?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91947</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-12 23:53:38 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; What happens if there&apos;s a script tag in there?

DOH.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91948</commentid>
    <comment_count>4</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-08-12 23:56:20 +0000</bug_when>
    <thetext>I don&apos;t think this needs to change the behavior of scripts. If we &apos;go&apos; at the end tag, this seems to fit nicely:

  &lt;x-a&gt;             
    &lt;x-a-1&gt;&lt;script&gt;&lt;/script&gt;&lt;/x-a-1&gt;  1
    &lt;script&gt;&lt;/script&gt;
  &lt;/x-a&gt;             2
  &lt;script&gt;&lt;/script&gt;
  &lt;x-b&gt;             
    &lt;x-b-1&gt;&lt;/x-b-1&gt;  3
  &lt;/x-b&gt;             4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91950</commentid>
    <comment_count>5</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-08-13 00:02:30 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; I don&apos;t think this needs to change the behavior of scripts. If we &apos;go&apos; at
&gt; the end tag, this seems to fit nicely:
&gt; 
&gt;   &lt;x-a&gt;             
&gt;     &lt;x-a-1&gt;&lt;script&gt;&lt;/script&gt;&lt;/x-a-1&gt;  1
&gt;     &lt;script&gt;&lt;/script&gt;
&gt;   &lt;/x-a&gt;             2
&gt;   &lt;script&gt;&lt;/script&gt;
&gt;   &lt;x-b&gt;             
&gt;     &lt;x-b-1&gt;&lt;/x-b-1&gt;  3
&gt;   &lt;/x-b&gt;             4

Upgrading one of these means running script (createdCallback) or at least having script-visible effects (prototype). So we need to number the script tags too. So you mean this should be:

4  &lt;x-a&gt;             
     &lt;x-a-1&gt;
1      &lt;script&gt;&lt;/script&gt;
2    &lt;/x-a-1&gt;
3    &lt;script&gt;&lt;/script&gt;
   &lt;/x-a&gt;
5  &lt;script&gt;&lt;/script&gt;
7  &lt;x-b&gt;             
6    &lt;x-b-1&gt;&lt;/x-b-1&gt;
   &lt;/x-b&gt;

?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91951</commentid>
    <comment_count>6</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-08-13 00:03:44 +0000</bug_when>
    <thetext>(In reply to comment #5)

Oops, I labelled a close tag. I meant:

4  &lt;x-a&gt;             
2    &lt;x-a-1&gt;
1      &lt;script&gt;&lt;/script&gt;
     &lt;/x-a-1&gt;
3    &lt;script&gt;&lt;/script&gt;
   &lt;/x-a&gt;
5  &lt;script&gt;&lt;/script&gt;
7  &lt;x-b&gt;             
6    &lt;x-b-1&gt;&lt;/x-b-1&gt;
   &lt;/x-b&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91961</commentid>
    <comment_count>7</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-08-13 03:39:02 +0000</bug_when>
    <thetext>In thinking about this more, the part of the spec that talks about prepending the callback queue for a created element to the element queue should change.

I think this is an opportunity to make things simpler and more regular; the created callback should simply be enqueued like any other.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92081</commentid>
    <comment_count>8</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-08-15 06:16:20 +0000</bug_when>
    <thetext>Custom Elements is now implemented this way in Blink.

An additional detail I&apos;m not sure we covered explicitly: Upgrade from post-hoc registration happens in the order it would have happened if the definition was available beforehand.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92717</commentid>
    <comment_count>9</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-29 22:47:25 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/webcomponents/rev/a53b6d2507cf</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>