Commit 7c8fc367 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_xhtml_style/erp5_web_renderjs_ui] Activate RSVP native promise async

parent 44f24691
...@@ -135,6 +135,29 @@ define("rsvp/async", ...@@ -135,6 +135,29 @@ define("rsvp/async",
var async; var async;
var local = (typeof global !== 'undefined') ? global : this; var local = (typeof global !== 'undefined') ? global : this;
function checkNativePromise() {
if (typeof Promise === "function" &&
typeof Promise.resolve === "function") {
try {
/* global Promise */
var promise = new Promise(function(){});
if ({}.toString.call(promise) === "[object Promise]") {
return true;
}
} catch (e) {}
}
return false;
}
function useNativePromise() {
var nativePromise = Promise.resolve();
return function(callback, arg) {
nativePromise.then(function () {
callback(arg);
});
};
}
// old node // old node
function useNextTick() { function useNextTick() {
return function(callback, arg) { return function(callback, arg) {
...@@ -196,6 +219,8 @@ define("rsvp/async", ...@@ -196,6 +219,8 @@ define("rsvp/async",
async = useNextTick(); async = useNextTick();
} else if (BrowserMutationObserver) { } else if (BrowserMutationObserver) {
async = useMutationObserver(); async = useMutationObserver();
} else if (checkNativePromise()) {
async = useNativePromise();
} else { } else {
async = useSetTimeout(); async = useSetTimeout();
} }
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>947.51153.11549.27255</string> </value> <value> <string>956.24426.45217.3157</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1450107607.48</float> <float>1484729690.52</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -135,6 +135,29 @@ define("rsvp/async", ...@@ -135,6 +135,29 @@ define("rsvp/async",
var async; var async;
var local = (typeof global !== 'undefined') ? global : this; var local = (typeof global !== 'undefined') ? global : this;
function checkNativePromise() {
if (typeof Promise === "function" &&
typeof Promise.resolve === "function") {
try {
/* global Promise */
var promise = new Promise(function(){});
if ({}.toString.call(promise) === "[object Promise]") {
return true;
}
} catch (e) {}
}
return false;
}
function useNativePromise() {
var nativePromise = Promise.resolve();
return function(callback, arg) {
nativePromise.then(function () {
callback(arg);
});
};
}
// old node // old node
function useNextTick() { function useNextTick() {
return function(callback, arg) { return function(callback, arg) {
...@@ -196,6 +219,8 @@ define("rsvp/async", ...@@ -196,6 +219,8 @@ define("rsvp/async",
async = useNextTick(); async = useNextTick();
} else if (BrowserMutationObserver) { } else if (BrowserMutationObserver) {
async = useMutationObserver(); async = useMutationObserver();
} else if (checkNativePromise()) {
async = useNativePromise();
} else { } else {
async = useSetTimeout(); async = useSetTimeout();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment