aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2011-03-27 16:19:03 -0700
committerIgor Minar2011-03-30 15:24:03 -0700
commita4863d52448170a8b94fa1fd2df79af1b66b6ad1 (patch)
tree42efebd35b150bdc70deac59e69e77377951d330 /src
parent96a1df192a167e6e34988af687693506f4efd1d1 (diff)
downloadangular.js-a4863d52448170a8b94fa1fd2df79af1b66b6ad1.tar.bz2
correct size() impl for object's w/ 'length' prop
the original implementation returned incorrect value value for objects with 'length' property.
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Angular.js b/src/Angular.js
index f4cb9b51..9a607ba3 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -487,17 +487,19 @@ function map(obj, iterator, context) {
*/
function size(obj, ownPropsOnly) {
var size = 0, key;
- if (obj) {
- if (isNumber(obj.length)) {
- return obj.length;
- } else if (isObject(obj)){
- for (key in obj)
- if (!ownPropsOnly || obj.hasOwnProperty(key))
- size++;
- }
+
+ if (isArray(obj) || isString(obj)) {
+ return obj.length;
+ } else if (isObject(obj)){
+ for (key in obj)
+ if (!ownPropsOnly || obj.hasOwnProperty(key))
+ size++;
}
+
return size;
}
+
+
function includes(array, obj) {
for ( var i = 0; i < array.length; i++) {
if (obj === array[i]) return true;