Standardizing __proto__
Mike Shaver
mike.shaver at gmail.com
Fri Mar 18 10:56:54 PDT 2011
On Fri, Mar 18, 2011 at 10:45 AM, Oliver Hunt <oliver at apple.com> wrote:
> I think so -- my proposal doesn't take instances, nor produce instances, it takes the constructor function (Image is one of a handful of DOM constructor that can actually be used to construct things) and returns a new constructor that will produce an instances of the target object with a modified prototype chain.
Andreas in IM that we hang it on the prototype chain, so that we get
it everywhere without repetitive specification. How about:
Function.prototype.createDelegatingTo = function (obj)
{
var o = new this; // really new-with-apply(arguments) here
o.__proto__ = obj;
return o;
}
Then Array.createDelegatingTo, Boolean.createDelegatingTo, Image, etc.
should all work. (I like the longer, grosser name because I think
it's sort of a gross pattern, and not something that should use up a
concise name.)
Mike
More information about the es-discuss
mailing list