浏览代码

Tiny fix for promise polyfill.all([])

David Catuhe 7 年之前
父节点
当前提交
3067636619
共有 1 个文件被更改,包括 7 次插入2 次删除
  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;
         }
     }