Add Object.isHash.
This commit is contained in:
parent
d195111a9d
commit
96af1b7579
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Add Object.isHash. [Tobie Langel]
|
||||
|
||||
* Performance improvements to String#times. [Martin Ström]
|
||||
|
||||
* Make Ajax.Response#getHeaderJSON and Ajax.Response#getResponseJSON pseudo private instance methods. [Tobie Langel]
|
||||
|
|
|
@ -131,6 +131,10 @@ Object.extend(Object, {
|
|||
return object && object.constructor === Array;
|
||||
},
|
||||
|
||||
isHash: function(object) {
|
||||
return object instanceof Hash;
|
||||
},
|
||||
|
||||
isFunction: function(object) {
|
||||
return typeof object == "function";
|
||||
},
|
||||
|
|
|
@ -39,7 +39,7 @@ var Hash = Class.create(Enumerable, (function() {
|
|||
|
||||
return {
|
||||
initialize: function(object) {
|
||||
this._object = object instanceof Hash ? object.toObject() : Object.clone(object);
|
||||
this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
|
||||
},
|
||||
|
||||
_each: each,
|
||||
|
|
|
@ -298,6 +298,12 @@
|
|||
assert(!Object.isArray({}));
|
||||
}},
|
||||
|
||||
testObjectIsHash: function() { with(this) {
|
||||
assert(Object.isHash($H()));
|
||||
assert(Object.isHash(new Hash()));
|
||||
assert(!Object.isHash({}));
|
||||
}},
|
||||
|
||||
testObjectIsElement: function() { with(this) {
|
||||
assert(Object.isElement(document.createElement('div')));
|
||||
assert(Object.isElement(new Element('div')));
|
||||
|
|
Loading…
Reference in New Issue