<?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>21888</bug_id>
          
          <creation_ts>2013-05-01 04:42:49 +0000</creation_ts>
          <short_desc>[Custom]: #dfn-custom-element-definition should be defined, and maybe registering a type extension of a custom tag should become an error?</short_desc>
          <delta_ts>2013-05-21 22:21:11 +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>Linux</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>18720</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Dominic Cooney">dominicc</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>87062</commentid>
    <comment_count>0</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-05-01 04:42:49 +0000</bug_when>
    <thetext>This bookmark &quot;#dfn-custom-element-definition&quot; is referred to from Step 1 of the element initialization algorithm but does not seem to be defined anywhere.

What I&apos;m trying to close in on is a simplification of the spec. Specifically, there&apos;s an asymmetry between document.register, which seems to admit setting up a type extension of a custom tag, for example:

XA = document.register(&apos;x-a&apos;);
XB = document.register(&apos;x-b&apos;, {prototype: XA.prototype});

and createElement/parsing which says that:

&quot;After a custom element is instantiated, changing the value of the is attribute must not affect this element&apos;s custom element name.

If both types of custom element names are provided at the time of element&apos;s instantiation, the custom tag must win over the type extension.&quot;

I&apos;m specifically worried about the difference in meaning between parsing &lt;x-a is=&quot;x-b&quot;&gt;&lt;/x-a&gt; and simply calling new XB().

For example, could this create a constructor XB that is almost an alias of XA, but has subtly different lifecycle callbacks?

p = Object.create(HTMLElement.prototype, {
  readyCallback: {value: t}
});
XA = document.register(&apos;x-a&apos;, {prototype: p});
XA.prototype.readyCallback = u;
XB = document.register(&apos;x-b&apos;, {prototype: XA.prototype});

Then:

  document.body.innerHTML = &apos;&lt;x-a&gt;&lt;/x-a&gt;&apos;

will call t. This is unsurprising.

  document.createElement(&apos;x-a&apos;, &apos;x-b&apos;)

will call t (because &quot;If both types of custom element names are provided at the time of element&apos;s instantiation, the custom tag must win over the type extension.&quot;)

  new XB()

may call u, or t, depending on what the meaning of &quot;Let DEFINITION be ELEMENT&apos;s definition&quot; (from the element initialization algorithm) is.

It seems extending a custom tag with another custom tag is reasonably well defined. Similarly, extending a type extension with another type extension squirrels up the prototype chain past the parent type extension to a built-in interface which isn&apos;t complicated with lifecycle callbacks. 

But extending a custom tag with a type extension begets ambiguity. I think it should be disallowed. I think that is what the intent of &quot;If both types of custom element names are provided at the time of element&apos;s instantiation, the custom tag must win over the type extension&quot; is, but the generated constructor is a loophole.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87379</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-05-07 21:12:16 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; This bookmark &quot;#dfn-custom-element-definition&quot; is referred to from Step 1 of
&gt; the element initialization algorithm but does not seem to be defined
&gt; anywhere.
&gt; 
&gt; What I&apos;m trying to close in on is a simplification of the spec.
&gt; Specifically, there&apos;s an asymmetry between document.register, which seems to
&gt; admit setting up a type extension of a custom tag, for example:
&gt; 
&gt; XA = document.register(&apos;x-a&apos;);
&gt; XB = document.register(&apos;x-b&apos;, {prototype: XA.prototype});
&gt; 
&gt; and createElement/parsing which says that:
&gt; 
&gt; &quot;After a custom element is instantiated, changing the value of the is
&gt; attribute must not affect this element&apos;s custom element name.
&gt; 
&gt; If both types of custom element names are provided at the time of element&apos;s
&gt; instantiation, the custom tag must win over the type extension.&quot;
&gt; 
&gt; I&apos;m specifically worried about the difference in meaning between parsing
&gt; &lt;x-a is=&quot;x-b&quot;&gt;&lt;/x-a&gt; and simply calling new XB().

In &lt;x-a is=&quot;x-b&quot;&gt;, the &quot;is&quot; value is simply ignored. It has no meaning, right (since the custom tag won)?

&gt; 
&gt; For example, could this create a constructor XB that is almost an alias of
&gt; XA, but has subtly different lifecycle callbacks?
&gt; 
&gt; p = Object.create(HTMLElement.prototype, {
&gt;   readyCallback: {value: t}
&gt; });
&gt; XA = document.register(&apos;x-a&apos;, {prototype: p});
&gt; XA.prototype.readyCallback = u;
&gt; XB = document.register(&apos;x-b&apos;, {prototype: XA.prototype});
&gt; 
&gt; Then:
&gt; 
&gt;   document.body.innerHTML = &apos;&lt;x-a&gt;&lt;/x-a&gt;&apos;
&gt; 
&gt; will call t. This is unsurprising.
&gt; 
&gt;   document.createElement(&apos;x-a&apos;, &apos;x-b&apos;)
&gt; 
&gt; will call t (because &quot;If both types of custom element names are provided at
&gt; the time of element&apos;s instantiation, the custom tag must win over the type
&gt; extension.&quot;)

Yes, because the author simply created an instance of XA here. The &quot;is&quot; value is ignored.

&gt; 
&gt;   new XB()
&gt; 
&gt; may call u, or t, depending on what the meaning of &quot;Let DEFINITION be
&gt; ELEMENT&apos;s definition&quot; (from the element initialization algorithm) is.
&gt; 
&gt; It seems extending a custom tag with another custom tag is reasonably well
&gt; defined. Similarly, extending a type extension with another type extension
&gt; squirrels up the prototype chain past the parent type extension to a
&gt; built-in interface which isn&apos;t complicated with lifecycle callbacks. 
&gt; 
&gt; But extending a custom tag with a type extension begets ambiguity. I think
&gt; it should be disallowed. I think that is what the intent of &quot;If both types
&gt; of custom element names are provided at the time of element&apos;s instantiation,
&gt; the custom tag must win over the type extension&quot; is, but the generated
&gt; constructor is a loophole.

I don&apos;t see where there&apos;s ambiguity. You simply can&apos;t use &quot;is&quot; with a custom tag. Can you help me understand better where the problem is?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87380</commentid>
    <comment_count>2</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-05-07 21:16:28 +0000</bug_when>
    <thetext>Fixed up links in https://dvcs.w3.org/hg/webcomponents/rev/a585db092558.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87395</commentid>
    <comment_count>3</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-05-08 00:06:31 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; (In reply to comment #0)
&gt; I don&apos;t see where there&apos;s ambiguity. You simply can&apos;t use &quot;is&quot; with a custom
&gt; tag. Can you help me understand better where the problem is?

Let me try again--sorry that was a bit of a ramble.

I think I was confused by the document.register steps.

If an author writes this code:

1: var A = document.register(&apos;x-a&apos;);
2: var B = document.register(&apos;x-b&apos;, {prototype: Object.create(A.prototype)});

Then on line 2, after register step 5.2, is INTERFACE going to be A or HTMLElement?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88031</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-05-21 22:21:11 +0000</bug_when>
    <thetext>I think I clarified this in https://dvcs.w3.org/hg/webcomponents/rev/ea07a8c6329c.

Please let me know if this still smells.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>