This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 20493 - [Custom]: Need to define, not set the "constructor" property on element prototype.
Summary: [Custom]: Need to define, not set the "constructor" property on element proto...
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on: 20653
Blocks: 17103
  Show dependency treegraph
 
Reported: 2012-12-22 00:55 UTC by Boris Zbarsky
Modified: 2013-05-08 15:23 UTC (History)
2 users (show)

See Also:


Attachments

Description Boris Zbarsky 2012-12-22 00:55:24 UTC
>"Set PROTOTYPE as the prototype property on CONSTRUCTOR
>Set CONSTRUCTOR as the constructor property on PROTOTYPE."

Those should be defining properties, not setting them.  Furthermore, those properties should have some non-default property attributes (which you have to think about once you start defining properties).  In particular, the .constructor of the prototype should not be enumerable (because otherwise enumeration on all the elements involved would see it!), and the .prototype of the constructor should probably not be configurable, writable, or enumerable (which is how WebIDL .prototype and standard class .prototype work), though this part we could at least argue about.
Comment 1 Dimitri Glazkov 2013-01-11 19:20:22 UTC
Since this is a function object, it will already have the "prototype" property per http://ecma-international.org/ecma-262/5.1/#sec-13.2

But you're right, I need to define the "constructor" property.
Comment 2 Boris Zbarsky 2013-01-11 19:34:06 UTC
> Since this is a function object, it will already have the "prototype" property

The spec section you link to is what happens if you create a function from a string.  It's not applicable here, unless you explicitly invoke it in the components spec (in which case you have to define the inputs to that algorithm and whatnot.. but I suspect you do not in fact want to go there, since you want these to be [native code] functions).

You should really look into how WebIDL defines its constructor objects and ideally share that definition....
Comment 3 Dimitri Glazkov 2013-01-11 20:51:27 UTC
(In reply to comment #2)
> > Since this is a function object, it will already have the "prototype" property
> 
> The spec section you link to is what happens if you create a function from a
> string.  It's not applicable here, unless you explicitly invoke it in the
> components spec (in which case you have to define the inputs to that
> algorithm and whatnot.. but I suspect you do not in fact want to go there,
> since you want these to be [native code] functions).
> 
> You should really look into how WebIDL defines its constructor objects and
> ideally share that definition....

(In reply to comment #2)
> > Since this is a function object, it will already have the "prototype" property
> 
> The spec section you link to is what happens if you create a function from a
> string.  It's not applicable here, unless you explicitly invoke it in the
> components spec (in which case you have to define the inputs to that
> algorithm and whatnot.. but I suspect you do not in fact want to go there,
> since you want these to be [native code] functions).

There's a not at the end that simply states:

"A prototype property is automatically created for every function, to allow for the possibility that the function will be used as a constructor."

Or is this not enough?

> 
> You should really look into how WebIDL defines its constructor objects and
> ideally share that definition....

Yup. And probably file bugs against WebIDL.
Comment 4 Boris Zbarsky 2013-01-11 21:11:24 UTC
A note at the end of the algorithm that's not being used here?

Seriously, this just needs to be defined.  It doesn't come for free with the current state of ES.
Comment 5 Dimitri Glazkov 2013-01-11 21:23:17 UTC
(In reply to comment #4)
> A note at the end of the algorithm that's not being used here?
> 
> Seriously, this just needs to be defined.  It doesn't come for free with the
> current state of ES.

Sounds good, filing bug against WebIDL here: http://www.w3.org/TR/WebIDL/#dfn-function-object
Comment 6 Dimitri Glazkov 2013-04-10 20:52:42 UTC
I ended up letting WebIDL do the work: "Let CONSTRUCTOR be the interface object whose interface prototype object is PROTOTYPE ...", which is defined pretty well in WebIDL.