This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
d88dc4a
commit 7829c50
Showing
2 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,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); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
petebacondarwin
Contributor
|
||
}; | ||
|
||
/** | ||
* @ngdoc function | ||
* @name angular.lowercase | ||
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Are these functions used? The code below doesn't seem to use them. Perhaps it should be?