<?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>21947</bug_id>
          
          <creation_ts>2013-05-07 05:29:42 +0000</creation_ts>
          <short_desc>[Custom]: Clarify registering HTMLElement.prototype as a prototype multiple times</short_desc>
          <delta_ts>2013-05-07 05:48:50 +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>INVALID</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="Dominic Cooney">dominicc</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>sjmiles</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>87306</commentid>
    <comment_count>0</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-05-07 05:29:42 +0000</bug_when>
    <thetext>If the author does this:

document.register(&apos;x-foo&apos;, {prototype: HTMLElement.prototype})

I think the current spec says implementations should throw a namespace error per step 5.4 (because HTMLElement does not inherit from HTMLElement.)

However that is really a coincidence; that step is designed to stop you extending elements outside the SVG and HTML namespaces.

I think defining multiple custom elements with the same prototype object should be an error (because the constructor property will be updated!) and extending HTMLElement.prototype directly sucks particularly because it is a widely shared object.

However if the decision is that a given prototype object can be used for multiple definitions, I think HTMLElement.prototype should be allowed to be (ab)used multiple times too.

Perhaps you could make document.register(&apos;x-foo&apos;, {prototype: HTMLElement.prototype}) to be sugar for Object.create(HTMLElement.prototype, {}) just like document.register(&apos;x-foo&apos;) is. The same could go for using any built-in interface prototype object directly like this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87307</commentid>
    <comment_count>1</comment_count>
    <who name="Scott Miles">sjmiles</who>
    <bug_when>2013-05-07 05:41:06 +0000</bug_when>
    <thetext>I&apos;m confused what you mean about overwriting the &apos;constructor&apos; property. 

Normally, the constructor of a prototype is the thing that constructed the prototype, not any constructor it is attached to.

IOW,

  P = {};
  c = P.constructor;

  Foo = function() {};
  Foo.prototype = P;
  assert(P.constructor === c); // true

  Bar = function() {};
  Bar.prototype = P;
  assert(P.constructor === c); // true

Are these prototypes handled differently somehow?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87308</commentid>
    <comment_count>2</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-05-07 05:48:50 +0000</bug_when>
    <thetext>Sorry, I misread the spec. The constructor generation algorithm says:

If PROTOTYPE is already an interface prototype object for any interface object or PROTOTYPE has a non-configurable property named constructor, throw a NotSupportedError and stop.

This is clear and obviates these issues. Sorry for the spam.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>