diff options
| author | Daniel Luz | 2013-07-08 11:00:59 +0100 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-07-08 11:05:08 +0100 |
| commit | 7829c50f9e89e779980f6d60a397aedfc7eaec61 (patch) | |
| tree | 6985e746735be488c179e9eaf061d3d17667dc28 /src/Angular.js | |
| parent | d88dc4a64f0cc1e83d0dd85ffffd254e72d23ca9 (diff) | |
| download | angular.js-7829c50f9e89e779980f6d60a397aedfc7eaec61.tar.bz2 | |
fix(angular.equals): do not match keys defined in the prototype chain
Merely testing for object[key] will give incorrect results on keys
defined in Object.prototype.
Note: IE8 is generally broken in this regard since `for...in` never returns
certain property keys even if they are defined directly on the object.
See #2141 - partially merges this PR
Diffstat (limited to 'src/Angular.js')
| -rw-r--r-- | src/Angular.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Angular.js b/src/Angular.js index 53b53239..98d32a7e 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -3,6 +3,16 @@ //////////////////////////////////// /** + * hasOwnProperty may be overriden by a property of the same name, or entirely + * absent from an object that does not inherit Object.prototype; this copy is + * used instead + */ +var hasOwnPropertyFn = Object.prototype.hasOwnProperty; +var hasOwnPropertyLocal = function(obj, key) { + return hasOwnPropertyFn.call(obj, key); +}; + +/** * @ngdoc function * @name angular.lowercase * @function @@ -685,7 +695,7 @@ function equals(o1, o2) { keySet[key] = true; } for(key in o2) { - if (!keySet[key] && + if (!keySet.hasOwnProperty(key) && key.charAt(0) !== '$' && o2[key] !== undefined && !isFunction(o2[key])) return false; |
