MDL-63210 core: convert for loop to forEach in JS
authorMark Nelson <markn@moodle.com>
Fri, 24 Aug 2018 03:31:32 +0000 (11:31 +0800)
committerMark Nelson <markn@moodle.com>
Fri, 24 Aug 2018 03:31:32 +0000 (11:31 +0800)
lib/amd/build/ajax.min.js
lib/amd/src/ajax.js

index a585b99..f8c5453 100644 (file)
Binary files a/lib/amd/build/ajax.min.js and b/lib/amd/build/ajax.min.js differ
index 088deca..a13cbcf 100644 (file)
@@ -79,14 +79,13 @@ define(['jquery', 'core/config', 'core/log', 'core/url'], function($, config, Lo
         }
         // Something failed, reject the remaining promises.
         if (exception !== null) {
-            // If the user isn't doing anything too important, redirect to the login page.
+            // Redirect to the login page.
             if (exception.errorcode === "servicerequireslogin") {
                 window.location = URL.relativeUrl("/login/index.php");
             } else {
-                for (; i < requests.length; i++) {
-                    request = requests[i];
+                requests.forEach(function(request) {
                     request.deferred.reject(exception);
-                }
+                });
             }
         }
     };