Browse Source

Tiny fix for promise polyfill.all([])

David Catuhe 7 years ago
parent
commit
3067636619
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/Tools/babylon.promise.ts

+ 7 - 2
src/Tools/babylon.promise.ts

@@ -200,10 +200,15 @@ module BABYLON {
             agregator.target = promises.length;
             agregator.rootPromise = newPromise;
 
-            for(var index = 0; index < promises.length; index++) {
-                InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
+            if (promises.length) {
+                for(var index = 0; index < promises.length; index++) {
+                    InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
+                }
+            } else {
+                newPromise._resolve();
             }
 
+
             return newPromise;
         }
     }