efront 4.0.23 → 4.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,14 +18,11 @@ if (!Promise) {
18
18
  var queue = [];
19
19
  var running = false;
20
20
  var run = function (q) {
21
- running = true;
22
21
  while (queue.length) {
23
22
  var threads = queue.splice(0, queue.length);
24
23
  for (var t of threads) {
25
- if (!t.oked && !t.ohed) continue;
26
24
  var PromiseRejectReactions = t.PromiseRejectReactions.splice(0, t.PromiseRejectReactions.length);
27
25
  var PromiseFulfillReactions = t.PromiseFulfillReactions.splice(0, t.PromiseFulfillReactions.length);
28
-
29
26
  if (t.oked) {
30
27
  for (var r of PromiseFulfillReactions) {
31
28
  r.call(null, t.oked[0]);
@@ -49,8 +46,9 @@ if (!Promise) {
49
46
  running = false;
50
47
  };
51
48
  var fire = function (p) {
52
- if (running) return queue.push(p);
53
49
  queue.push(p);
50
+ if (running) return;
51
+ running = true;
54
52
  requestAnimationFrame(run);
55
53
  };
56
54
  var Promise = function (executor) {
@@ -72,39 +70,38 @@ if (!Promise) {
72
70
  p.ohed = arguments;
73
71
  fire(p);
74
72
  };
75
- fire(p);
76
73
  executor(ResolvingFunctions_resolve, ResolvingFunctions_reject);
77
74
  };
78
- Promise.prototype = {
79
- then(onok, onoh) {
80
- var resolve, reject;
81
- var promise = new Promise(function (ok, oh) {
82
- if (onok) resolve = function (a) {
83
- try {
84
- a = onok(a);
85
- ok(a);
86
- } catch (e) {
87
- oh(e, onok, onoh);
88
- }
89
- };
90
- if (onoh) reject = function (a) {
91
- try {
92
- a = onoh.apply(null, arguments);
93
- ok(a);
94
- } catch (e) {
95
- oh(e, onok, onoh);
96
- }
97
- };
98
- })
99
- if (resolve) this.PromiseFulfillReactions.push(resolve);
100
- if (reject) this.PromiseRejectReactions.push(reject);
101
- if (this.oked || this.ohed) fire(this);
102
- return promise;
103
- },
104
- "catch"(f) {
105
- return this.then(null, f);
106
- },
75
+ Promise.prototype.then = function (onok, onoh) {
76
+ var resolve, reject;
77
+ var promise = new Promise(function (ok, oh) {
78
+ if (onok) resolve = function (a) {
79
+ try {
80
+ a = onok(a);
81
+ ok(a);
82
+ } catch (e) {
83
+ oh(e, onok, onoh);
84
+ }
85
+ };
86
+ else resolve = ok;
87
+ if (onoh) reject = function (a) {
88
+ try {
89
+ a = onoh.apply(null, arguments);
90
+ ok(a);
91
+ } catch (e) {
92
+ oh(e, onok, onoh);
93
+ }
94
+ };
95
+ else reject = oh;
96
+ })
97
+ if (resolve) this.PromiseFulfillReactions.push(resolve);
98
+ if (reject) this.PromiseRejectReactions.push(reject);
99
+ if (this.oked || this.ohed) fire(this);
100
+ return promise;
107
101
  }
102
+ Promise.prototype.catch = function (f) {
103
+ return this.then(null, f);
104
+ };
108
105
  Promise.all = function (penddings) {
109
106
  return new Promise(function (ok, oh) {
110
107
  if (!(penddings && penddings.length)) {
@@ -11,6 +11,7 @@ async function testCatch(Promise) {
11
11
  }).then(null, function () {
12
12
  console.log("catch2");
13
13
  });
14
+ console.log("done");
14
15
  } catch (e) {
15
16
  console.log(e)
16
17
  }
@@ -18,7 +18,9 @@ if (cookiesData) {
18
18
  }
19
19
 
20
20
  var digest = function () {
21
- dispatch('render', window);
21
+ Promise.resolve().then(function(){
22
+ dispatch('render', window);
23
+ });
22
24
  };
23
25
  if (/Trident/i.test(navigator.userAgent)) digest = lazy(digest, 60);
24
26
  var cross = cross_.bind(function (callback, onerror) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.0.23",
3
+ "version": "4.0.24",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {