Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 2af2607

Browse files
frederikprijckgkalpak
authored andcommittedFeb 8, 2017
fix(filterFilter): don't throw if key.charAt is not a function
Previously, when an object has keys which are not of type string, `filterFilter` would throw an exception for trying to call `key.charAt()`, which is a string method. This commit checks whether `charAt` is defined before calling it. Fixes #15644 Closes #15660
1 parent a0641ea commit 2af2607

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎src/ng/filter/filter.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstA
226226
var key;
227227
if (matchAgainstAnyProp) {
228228
for (key in actual) {
229-
if ((key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, anyPropertyKey, true)) {
229+
// Under certain, rare, circumstances, key may not be a string and `charAt` will be undefined
230+
// See: https://github.com/angular/angular.js/issues/15644
231+
if (key.charAt && (key.charAt(0) !== '$') &&
232+
deepCompare(actual[key], expected, comparator, anyPropertyKey, true)) {
230233
return true;
231234
}
232235
}

0 commit comments

Comments
 (0)
This repository has been archived.