diff options
| author | Igor Minar | 2012-03-13 10:02:56 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-03-13 14:13:53 -0700 |
| commit | b6ae6e52f99c0c3c45ad787328a2e800ff07ca2c (patch) | |
| tree | 61cdc3f9d1739f21c08646807f6785ee2144bd30 | |
| parent | 9277d12fc0052efacbeed7cf9aaeea608e5f6108 (diff) | |
| download | angular.js-b6ae6e52f99c0c3c45ad787328a2e800ff07ca2c.tar.bz2 | |
fix(indexOf): use native impl if available
| -rw-r--r-- | src/Angular.js | 7 | ||||
| -rw-r--r-- | src/directive/form.js | 6 |
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 = []; |
