소스 검색

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

huqi 5 년 전
부모
커밋
eee0bd1016
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  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){
     var _promiseAll = function(p){
         if (o2.typeOf(p)=="array"){
         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);
                 return Promise.all(p);
             }else{
             }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{
         }else{
             if (p && o2.typeOf(p.then)=="function"){
             if (p && o2.typeOf(p.then)=="function"){
                 return Promise.resolve(p);
                 return Promise.resolve(p);
             }else{
             }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";
         // var method = (o2.typeOf(p)=="array") ? "all" : "resolve";