aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2013-01-17 16:53:30 -0800
committerIgor Minar2013-01-17 17:48:51 -0800
commit5ae63fd385295d5a7bbdc79466f59727dcab1c85 (patch)
treeca636c897a063dbbd44b91128d2dbe5db0672672 /src
parent8b4432481472f13e995df6dc437d55d87b38b709 (diff)
downloadangular.js-5ae63fd385295d5a7bbdc79466f59727dcab1c85.tar.bz2
fix(angular.equals): consistently compare undefined object props
previously: a = {}; b = {x:undefined}; angular.equals(a, b) == angular.equals(b, a) // returns false. both should return false because these objects are not equal. unlike in implemented in #1695 the comparison should be stricter and return false not true. if we need to relax this in the future we can always do so. Closes #1648
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 3a11f3ea..21b3ef07 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -620,16 +620,23 @@ function equals(o1, o2) {
} else {
if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2)) return false;
keySet = {};
+ length = 0;
for(key in o1) {
- if (key.charAt(0) !== '$' && !isFunction(o1[key]) && !equals(o1[key], o2[key])) {
- return false;
- }
+ if (key.charAt(0) === '$') continue;
+
+ if (!isFunction(o1[key]) && !equals(o1[key], o2[key])) return false;
+
+ length++;
keySet[key] = true;
}
for(key in o2) {
- if (!keySet[key] && key.charAt(0) !== '$' && !isFunction(o2[key])) return false;
+ if (key.charAt(0) === '$') {
+ continue;
+ }
+ if (!keySet[key] && !isFunction(o2[key])) return false;
+ length--;
}
- return true;
+ return length === 0;
}
}
}