aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Angular.js7
-rw-r--r--src/directive/form.js6
2 files changed, 4 insertions, 9 deletions
diff --git a/src/Angular.js b/src/Angular.js
index cdffcf1d..282dad5f 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -503,13 +503,12 @@ function size(obj, ownPropsOnly) {
function includes(array, obj) {
- for ( var i = 0; i < array.length; i++) {
- if (obj === array[i]) return true;
- }
- return false;
+ return indexOf(array, obj) != -1;
}
function indexOf(array, obj) {
+ if (array.indexOf) return array.indexOf(obj);
+
for ( var i = 0; i < array.length; i++) {
if (obj === array[i]) return i;
}
diff --git a/src/directive/form.js b/src/directive/form.js
index db645188..8c172889 100644
--- a/src/directive/form.js
+++ b/src/directive/form.js
@@ -98,11 +98,7 @@ function FormController(name, element) {
function addControlError(validationToken, control) {
var queue = errors[validationToken];
if (queue) {
- for (var i = 0, length = queue.length; i < length; i++) {
- if (queue[i] === control) {
- return;
- }
- }
+ if (indexOf(queue, control)) return;
} else {
errors[validationToken] = queue = [];