On Mar 6, 5:49 am, Jim Higson <j...@wikizzle.org> wrote:
> On Thursday 05 March 2009 23:22:26 Tobie Langel wrote:
>
> > Hi,
>
> > Extending Object.prototype is regarded as a Bad Thing[1].
>
> Does Prototype state anywhere that it doesn't work if Object.prototype is
> extended? If this is a stated limitation then fair enough I guess.

I think not, but probably should. Mind creating a ticket?

>
> It seems like some parts of Prototype are designed to work with code that adds
> to Object.Prototype, for example in the Hash class we have:
>
>     get: function(key) {
>       // simulating poorly supported hasOwnProperty
>       if (this._object[key] !== Object.prototype[key])
>         return this._object[key];
>     },

Not exactly. The fact that it "works" with augmented
`Object.prototype` is only a consequence of another workaround :) The
check is there to return only user-defined "keys"; Even without
`Object.prototype` modification, you would get unexpected result when
querying for, say, `toString` on a new Hash instance:

$H({ foo: 1, bar: 2 }).get('toString');

It's possible that we'll introduce a custom `hasOwnProperty` in later
revisions.

>
> > The main reason being that cross-browser support for hasOwnProperty is
> > fairly recent (Safari 2 doesn't have it for example).
>
> I didn't know that, thanks for the info. What happens if you use
> hasOwnProperty in Safari 2?

"Use" as in try to call it? IIRC, you get "hasOwnProperty is not a
function" error. In other words, it simply doesn't exist : )

>
> I don't have any usage statistics but I'd guess Safari 2 isn't used much now.
> According to Wikipedia the last version was 2.0.4, released 13th January 2006
> and was replaced with 3.0.0 on the 11th June 2007.

Yeah, Safari 2 is pretty close to being out.

[...]

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to