On Sep 13, 9:32 am, Yaffle <vic99...@yandex.ru> wrote:
> var h = $H({});
> h.set('__proto__','sadfdsf');
> alert( typeof( h.get('__proto__') ));

That's a known limitation, actually (although, probably not documented
anywhere). There's no key coercion in Prototype's Hash implementation,
which is why setting `__proto__` actually mutates [[Prototype]] of an
object that hash uses internally to store its values (btw, in Mozilla
`__proto__` can only be set once, contrary to, say, WebKit).

> Also try these:
> alert(Object.toQueryString('hasOwnProperty=1'.toQueryParams()));
> // hasOwnProperty=function%20()%20%7B%20%5Bnative%20code%5D
> %20%7D&hasOwnProperty=1
> May be  "Object.prototype.hasOwnProperty.call(hash,key)" should be
> used instead of 'key in hash' operator?

We didn't use `hasOwnProperty` since it was missing in Safari <2.0.4
(which we supported back then). Now that support for Safari 2.0.4 is
dropped, I still wouldn't use `hasOwnProperty`, as it's not as
reliable as it seems. For example, that same "__proto__" is being
reported as *own* property of an object in Mozilla and will still mess
things up. There could also be other non-standard magic properties
with unknown behavior. String coercion usually avoids this problem,
albeit in expense of slight performance decrease.

Also take a look at this related discussion -

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to