Ensure Hash does not return keys from the prototype chain (e.g., constructor, valueOf, toString).
This commit is contained in:
parent
64002a9083
commit
b31f642e64
|
@ -1,3 +1,5 @@
|
|||
* Ensure Hash does not return keys from the prototype chain (e.g., constructor, valueOf, toString). (kangax)
|
||||
|
||||
* Fix toString/valueOf sharing same method reference via closure in Class#addMethods. Use plain property assignment, since Object.extend fails to enumerate over toString/valueOf. (kangax)
|
||||
|
||||
* Stop Form.Element.disable from stealing focus. (jddalton)
|
||||
|
|
|
@ -28,7 +28,9 @@ var Hash = Class.create(Enumerable, (function() {
|
|||
},
|
||||
|
||||
get: function(key) {
|
||||
return this._object[key];
|
||||
// simulating poorly supported hasOwnProperty
|
||||
if (this._object[key] !== Object.prototype[key])
|
||||
return this._object[key];
|
||||
},
|
||||
|
||||
unset: function(key) {
|
||||
|
|
|
@ -14,6 +14,9 @@ new Test.Unit.Runner({
|
|||
this.assertEqual('A', h.get('a'));
|
||||
this.assertUndefined(h.a);
|
||||
this.assertUndefined($H({}).get('a'));
|
||||
|
||||
this.assertUndefined($H({}).get('toString'));
|
||||
this.assertUndefined($H({}).get('constructor'));
|
||||
},
|
||||
|
||||
testUnset: function() {
|
||||
|
|
Loading…
Reference in New Issue