prototype: Make Object.isArray correctly identify arrays created in another frame. Closes #10374.
This commit is contained in:
parent
7942a9e5c9
commit
17cd2f9f8d
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Make Object.isArray correctly identify arrays created in another frame. Closes #10374. [pointy, Dean Edwards, Andrew Dupont, Tobie Langel]
|
||||
|
||||
* Fixed issue where Element#match failed on attribute selectors with single or double quotes. Closes #10067. [Cezary Okupski, Andrew Dupont]
|
||||
|
||||
* Add tests for Element#match. [Tobie Langel]
|
||||
|
@ -132,7 +132,8 @@ Object.extend(Object, {
|
||||
},
|
||||
|
||||
isArray: function(object) {
|
||||
return object && object.constructor === Array;
|
||||
return object != null && typeof object == "object" &&
|
||||
'splice' in object && 'join' in object;
|
||||
},
|
||||
|
||||
isHash: function(object) {
|
||||
|
@ -22,7 +22,12 @@
|
||||
|
||||
<!-- Log output -->
|
||||
<div id="testlog"> </div>
|
||||
<div id="test"></div>
|
||||
<div id="test"></div>
|
||||
<ul id="list">
|
||||
<li></li>
|
||||
<li></li>
|
||||
<li></li>
|
||||
</ul>
|
||||
<!-- Tests follow -->
|
||||
<script type="text/javascript" language="javascript" charset="utf-8">
|
||||
// <![CDATA[
|
||||
@ -311,6 +316,16 @@
|
||||
assert(Object.isArray([0]));
|
||||
assert(Object.isArray([0, 1]));
|
||||
assert(!Object.isArray({}));
|
||||
assert(!Object.isArray($('list').childNodes));
|
||||
assert(!Object.isArray());
|
||||
assert(!Object.isArray(''));
|
||||
assert(!Object.isArray('foo'));
|
||||
assert(!Object.isArray(0));
|
||||
assert(!Object.isArray(1));
|
||||
assert(!Object.isArray(null));
|
||||
assert(!Object.isArray(true));
|
||||
assert(!Object.isArray(false));
|
||||
assert(!Object.isArray(undefined));
|
||||
}},
|
||||
|
||||
testObjectIsHash: function() { with(this) {
|
||||
|
Loading…
Reference in New Issue
Block a user