Explorar o código

Tiny fix for promise polyfill.all([])

David Catuhe %!s(int64=7) %!d(string=hai) anos
pai
achega
3067636619
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  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;
         }
     }