From 2bcc73f3f4b7759b0905341f4fda7c27a2961311 Mon Sep 17 00:00:00 2001 From: "PRIJCK Frederik (FPRJ)" Date: Wed, 1 Feb 2017 08:21:11 +0100 Subject: [PATCH 1/2] fix(filter): Don't throw `key.charAt is not a function` when object's keys are not of type `string`. Previously, when an object has keys which are not of type string, the `filter` would throw an exception for trying to call `charAt`, which is not defined on a none-string type. This commit checks whether `charAt` is defined before calling it. Closes #15644 --- src/ng/filter/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/filter/filter.js b/src/ng/filter/filter.js index a0b49948d55c..c47422dc9c2a 100644 --- a/src/ng/filter/filter.js +++ b/src/ng/filter/filter.js @@ -226,7 +226,7 @@ function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstA var key; if (matchAgainstAnyProp) { for (key in actual) { - if ((key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, anyPropertyKey, true)) { + if (key.charAt && (key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, anyPropertyKey, true)) { return true; } } From b84bcba11e03e0261056f90e9c266346999b5ed5 Mon Sep 17 00:00:00 2001 From: Frederik Prijck Date: Wed, 1 Feb 2017 19:55:24 +0100 Subject: [PATCH 2/2] fixup! fix(filter): Don't throw `key.charAt is not a function` when object's keys are not of type `string`. --- src/ng/filter/filter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ng/filter/filter.js b/src/ng/filter/filter.js index c47422dc9c2a..acecd9244c2e 100644 --- a/src/ng/filter/filter.js +++ b/src/ng/filter/filter.js @@ -226,6 +226,8 @@ function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstA var key; if (matchAgainstAnyProp) { for (key in actual) { + // Under certain, rare, circumstances, key may not be a string and `charAt` will be undefined + // See: https://github.com/angular/angular.js/issues/15644 if (key.charAt && (key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, anyPropertyKey, true)) { return true; }