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.
> 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?
-- 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]