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",
var async;
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
function useNextTick() {
return function(callback, arg) {
......@@ -196,6 +219,8 @@ define("rsvp/async",
async = useNextTick();
} else if (BrowserMutationObserver) {
async = useMutationObserver();
} else if (checkNativePromise()) {
async = useNativePromise();
} else {
async = useSetTimeout();
}
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>947.51153.11549.27255</string> </value>
<value> <string>956.24426.45217.3157</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1450107607.48</float>
<float>1484729690.52</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -135,6 +135,29 @@ define("rsvp/async",
var async;
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
function useNextTick() {
return function(callback, arg) {
......@@ -196,6 +219,8 @@ define("rsvp/async",
async = useNextTick();
} else if (BrowserMutationObserver) {
async = useMutationObserver();
} else if (checkNativePromise()) {
async = useNativePromise();
} else {
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