Skip to content

Commit b6ae6e5

Browse files
committed
fix(indexOf): use native impl if available
1 parent 9277d12 commit b6ae6e5

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Angular.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,12 @@ function size(obj, ownPropsOnly) {
503503

504504

505505
function includes(array, obj) {
506-
for ( var i = 0; i < array.length; i++) {
507-
if (obj === array[i]) return true;
508-
}
509-
return false;
506+
return indexOf(array, obj) != -1;
510507
}
511508

512509
function indexOf(array, obj) {
510+
if (array.indexOf) return array.indexOf(obj);
511+
513512
for ( var i = 0; i < array.length; i++) {
514513
if (obj === array[i]) return i;
515514
}

src/directive/form.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ function FormController(name, element) {
9898
function addControlError(validationToken, control) {
9999
var queue = errors[validationToken];
100100
if (queue) {
101-
for (var i = 0, length = queue.length; i < length; i++) {
102-
if (queue[i] === control) {
103-
return;
104-
}
105-
}
101+
if (indexOf(queue, control)) return;
106102
} else {
107103
errors[validationToken] = queue = [];
108104

0 commit comments

Comments
 (0)