<?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>27016</bug_id>
          
          <creation_ts>2014-10-10 13:06:36 +0000</creation_ts>
          <short_desc>[Custom]: Custom element constructor behavior makes no sense</short_desc>
          <delta_ts>2015-07-06 08:08:23 +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>MOVED</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="Boris Zbarsky">bzbarsky</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>annevk</cc>
    
    <cc>gkrizsanits</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112945</commentid>
    <comment_count>0</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-10-10 13:06:36 +0000</bug_when>
    <thetext>It starts with:

  1.  Let ELEMENT be the context object

But there is no context object here.  This is the constructor; it needs to create the element.  The element doesn&apos;t exist yet at this point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112959</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2014-10-10 16:23:48 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #0)
&gt; It starts with:
&gt; 
&gt;   1.  Let ELEMENT be the context object
&gt; 
&gt; But there is no context object here.  This is the constructor; it needs to
&gt; create the element.  The element doesn&apos;t exist yet at this point.

If you look at http://es5.github.io/#x13.2.2, you can clearly see that the constructor is actually called on an object after it is created.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112961</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-10-10 16:42:39 +0000</bug_when>
    <thetext>You&apos;re not defining the [[Construct]].

You&apos;re defining part of the [[Call]] of the Web IDL constructor, which doesn&apos;t have a useful context object as Web IDL is specified right now.  In particular, the &quot;this&quot; value when the [[Call]] is invoked in this case is some random JS object (the one the default [[Construct]] allocated), not an Element instance.

In particular, the relevant part of Web IDL is step 5 of the [[Call]] internal method of interface objects, which does:

 5. Let R be the result of performing the actions listed in the description of
    constructor with values as the argument values. 

and what you&apos;re doing is providing said list of actions. Which means its result needs to be R (in this case the Element).

Once ES6 gets its @@create/whatever story in order and Web IDL is updated accordingly we&apos;ll see what custom elements needs to say here to sync up with that.  But for now what it says is nonsensical, sorry.  It needs to be actually creating the element it wants to return from [[Call]].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112962</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2014-10-10 17:07:36 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #2)
&gt; You&apos;re not defining the [[Construct]].

No, I am defining F in that algo. I could make that more clear. The verbiage just before that (&quot;Let CONSTRUCTOR be the interface object whose interface prototype object is PROTOTYPE and when called as a constructor, executes these steps&quot;) tries to do the thing you&apos;re describing below.

&gt; 
&gt; You&apos;re defining part of the [[Call]] of the Web IDL constructor, which
&gt; doesn&apos;t have a useful context object as Web IDL is specified right now.  In
&gt; particular, the &quot;this&quot; value when the [[Call]] is invoked in this case is
&gt; some random JS object (the one the default [[Construct]] allocated), not an
&gt; Element instance.
&gt; 
&gt; In particular, the relevant part of Web IDL is step 5 of the [[Call]]
&gt; internal method of interface objects, which does:
&gt; 
&gt;  5. Let R be the result of performing the actions listed in the description
&gt; of
&gt;     constructor with values as the argument values. 
&gt; 
&gt; and what you&apos;re doing is providing said list of actions. Which means its
&gt; result needs to be R (in this case the Element).
&gt; 
&gt; Once ES6 gets its @@create/whatever story in order and Web IDL is updated
&gt; accordingly we&apos;ll see what custom elements needs to say here to sync up with
&gt; that.  But for now what it says is nonsensical, sorry.  It needs to be
&gt; actually creating the element it wants to return from [[Call]].

Right. In a way, I am trying to straddle the magical Web IDL land and the barren ES5 land until ES6 comes along. Would love any specific diffs/patches on how that could be made better.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112963</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-10-10 17:30:42 +0000</bug_when>
    <thetext>&gt; No, I am defining F in that algo.

Ah.  So you&apos;re defining the steps that http://people.mozilla.org/~jorendorff/es6-draft.html#sec-built-in-function-objects-call-thisargument-argumentslist executes in step 9?

But then this thing is not an &quot;interface object&quot; in the Web IDL sense, as you claim, because those in fact define different such steps.  We need to harmonize this somehow.

In any case, if these are steps for step 9 of [[Call]] they still have the problem I described.

&gt; tries to do the thing you&apos;re describing below

I don&apos;t believe it succeeds, sorry.

&gt; Would love any specific diffs/patches on how that could be made better.

My suggestion for how to do that is in comment 2: you say that this is a Web IDL constructor and then define the &quot;actions listed in the description&quot; to create and return an element with the right bits set.  It&apos;s pretty much what you have, except instead of setting the (immutable) localName and namespace and so forth of the element you want to do something similar to what createElementNS does.

On a side note, step 3 of http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-constructor-generation seems to be dead?  &quot;REGISTRY&quot; is never used...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121623</commentid>
    <comment_count>5</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-07-06 08:02:51 +0000</bug_when>
    <thetext>Moved to https://github.com/w3c/webcomponents/issues/189</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121673</commentid>
    <comment_count>6</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-07-06 08:08:23 +0000</bug_when>
    <thetext>Moved to https://github.com/w3c/webcomponents/issues/189</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>