aboutsummaryrefslogtreecommitdiffstats
path: root/src/Angular.js
diff options
context:
space:
mode:
authorDaniel Herman2013-07-25 23:15:57 -0400
committerKen Sheedlo2013-07-31 11:08:56 -0700
commitfad626f3047cd4ff31fe7a4181ca63f275adbae6 (patch)
tree28b4ee89d0cbe8867c84d000243463586e409415 /src/Angular.js
parent000012f3196776bb1d4b5df802c6763e514c0fb9 (diff)
downloadangular.js-fad626f3047cd4ff31fe7a4181ca63f275adbae6.tar.bz2
fix(isArrayLike) Correctly detect arrayLike items
Change the implementation of isArrayLike to use one heavily based on the implementation in jQuery in order to correctly detect array-like objects, that way functionality like ngRepeat works as expected.
Diffstat (limited to 'src/Angular.js')
-rw-r--r--src/Angular.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 27b85419..0252a720 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -80,19 +80,19 @@ var /** holds major version number for IE or NaN for real browsers */
* @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, ...)
*/
function isArrayLike(obj) {
- if (!obj || (typeof obj.length !== 'number')) return false;
+ if (obj == null || isWindow(obj)) {
+ return false;
+ }
+
+ var length = obj.length;
- // We have on object which has length property. Should we treat it as array?
- if (typeof obj.hasOwnProperty != 'function' &&
- typeof obj.constructor != 'function') {
- // This is here for IE8: it is a bogus object treat it as array;
+ if (obj.nodeType === 1 && length) {
return true;
- } else {
- return obj instanceof JQLite || // JQLite
- (jQuery && obj instanceof jQuery) || // jQuery
- toString.call(obj) !== '[object Object]' || // some browser native object
- typeof obj.callee === 'function'; // arguments (on IE8 looks like regular obj)
}
+
+ return isArray(obj) || !isFunction(obj) && (
+ length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj
+ );
}
/**