Răsfoiți Sursa

修复promiseAll方法为空数组时的问题

huqi 5 ani în urmă
părinte
comite
eee0bd1016
1 a modificat fișierele cu 5 adăugiri și 3 ștergeri
  1. 5 3
      o2web/source/o2_core/o2.js

+ 5 - 3
o2web/source/o2_core/o2.js

@@ -1862,16 +1862,18 @@ if (!window.Promise){
 
     var _promiseAll = function(p){
         if (o2.typeOf(p)=="array"){
-            if (p.some(function(e){ return (o2.typeOf(e.then)=="function") })){
+            if (p.some(function(e){ return (e && o2.typeOf(e.then)=="function") })){
                 return Promise.all(p);
             }else{
-                return { "then": function(s){ s(p); return this;} };
+                //return { "then": function(s){ s(p); return this;} };
+                return new Promise(function(s){s(p); return this;});
             }
         }else{
             if (p && o2.typeOf(p.then)=="function"){
                 return Promise.resolve(p);
             }else{
-                return { "then": function(s){ s(p); return this;} };
+                //return { "then": function(s){ s(p); return this;} };
+                return new Promise(function(s){s(p); return this;});
             }
         }
         // var method = (o2.typeOf(p)=="array") ? "all" : "resolve";