On Tue, Oct 25, 2011 at 4:08 PM, Scott Sauyet <[email protected]>wrote:

> Jake Verbaten wrote:
> > Scott Sauyet wrote:
>
> >> I simply have never been quite certain when I can depend upon
> >> Object.create being present and functioning correctly.  And I'm wary
> >> of shims which can never do what the original is supposed to do.
> >> Which is why I still mostly use:
> >
> >>    var F = function() {};
> >>    F.prototype = Parent.prototype;
> >>    Child.prototype = new F();
> >
> >> This is perhaps less obvious than Object.create, but it's a well-known
> >> pattern, and I'm quite certain that the environments I care about
> >> support it., especially as my current project has to support IE7, and
> >> I would like it to support older versions of FF as well.
> >
> > ES5 shim <https://github.com/kriskowal/es5-shim> will shim out a
> sensible
> > subset of ES5.
> >
> > For example object.create(proto) works completely. Object.create(proto,
> pds)
> > works for some subset of pds.  [ ... ]
>
> One person's sensible subset may be another's hopelessly crippled
> implementation.  It's not that I think Kris Kowal's implementation has
> anything wrong with it.  I tried it on several small projects and had
> no issues whatsoever.  But I'm working on a large project now with
> many team members who might well expect it to work too much like the
> ES5 spec.  And like all of us, most of their testing is in browsers
> which support Object.create.  If there are subtle problems because of
> a shim that's not as complete as would be preferred, they might get
> buried in code that becomes difficult to change.  If the code fails
> hard the first time someone tries the application in IE8, these
> changes won't get quickly buried.
>

Meh, the documentaiton on the README says which shims do not work. Any
competent team member should be able to "know" the sensible subset of ES5
from reading that.


>
> > however we are suggesting you use Object.create(proto) not
> > Object.create(proto, pd) the former works completely cross browser.
>
> I'm curious if you object to the formulation above, which of course is
> doing much the same as any of the Object.create shims.  (I usually
> wrap in in a function with a name like `inherit`.)  Do you see a
> problem with skipping the `Object.create` calls and going directly
> with manipulation of the prototype of an empty constructor?
>

If you take a look at my pd project you see I really dislike handling `new
<Function>` or constructor functions by hand. As far as I can see your code
will work but it feels really ugly and un-elegant.

I'd personally just call that function you normally call `inherit`
Object.create (except the latter operates on objects not constructor
functions).


>
>  -- Scott
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to