<?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>24018</bug_id>
          
          <creation_ts>2013-12-06 15:40:58 +0000</creation_ts>
          <short_desc>[Custom]: No way to pass parameters to constructor</short_desc>
          <delta_ts>2014-05-12 22:14:16 +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>14968</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Erik Arvidsson">erik.arvidsson</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>97245</commentid>
    <comment_count>0</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2013-12-06 15:40:58 +0000</bug_when>
    <thetext>DOM has a bunch of element constructors that take parameters. `new Image(src)` for example. Custom elements fail in this regard. The following should just work.

```js
class MyElement extends HTMLElement {
  constructor(text) {
    this.textContent = text;
  }
}
MyElement = document.register(&apos;my-element&apos;, MyElement);
new MyElement(&apos;Hi&apos;);
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97285</commentid>
    <comment_count>1</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-12-08 00:21:58 +0000</bug_when>
    <thetext>I think this should be addressed in Level 2 of the Custom Elements spec, or in a related spec. Chrome is not in a position to implement this now.

Does ES6 make it possible to detect whether a function is a &quot;class&quot; or has a constructor?

I believe this is a simple matter of specifying that, for such functions, the generated constructor passes arguments to the argument&apos;s constructor.

It would be useful for someone with deep familiarity with ES6 to explain in what other ways the generated constructor should be configured.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97296</commentid>
    <comment_count>2</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2013-12-08 23:15:26 +0000</bug_when>
    <thetext>&gt; Does ES6 make it possible to detect whether a function is a &quot;class&quot; or has a constructor?

There is no difference between a class and a function. The only way to tell the difference is in what Function.prototype.toString would return. http://people.mozilla.org/~jorendorff/es6-draft.html#sec-function.prototype.tostring

The constructor is always the function representing the class.

```js
class C {}
assert(C === C.prototype.constructor);

class C2 {
  constructor() {}
}
assert(C2 === C2.prototype.constructor);
```

Just like `Date === Date.prototype.contstructor` and `HTMLElement === HTMLElement.prototype.constructor`.

When writing &quot;classes&quot; using ES3/ES5 libraries such as Closure, Backbone, Ember, Ext.js, YUI etc they will set up the prototype.constructor so that this equivalence also holds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97299</commentid>
    <comment_count>3</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-12-09 00:44:27 +0000</bug_when>
    <thetext>(In reply to Erik Arvidsson from comment #2)
&gt; &gt; Does ES6 make it possible to detect whether a function is a &quot;class&quot; or has a constructor?
&gt; 
&gt; There is no difference between a class and a function.

OK. So it makes sense to pass the parameters through in the case where the second argument to register is a function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105771</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2014-05-12 22:14:16 +0000</bug_when>
    <thetext>Addressed in https://github.com/w3c/webcomponents/commit/03f1382155de885c63cca9cdd78fdf34c72fa495</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>