Commit b55ca2e2 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_xhtml_style/web_renderjs_ui] renderJS 0.23.0

parent 1f5d97ca
...@@ -763,18 +763,12 @@ if (typeof document.contains !== 'function') { ...@@ -763,18 +763,12 @@ if (typeof document.contains !== 'function') {
try { try {
result = callback.apply(context, argument_list); result = callback.apply(context, argument_list);
} catch (e) { } catch (e) {
return new RSVP.Queue() return new RSVP.Queue(RSVP.reject(e));
.push(function returnPushableError() {
return RSVP.reject(e);
});
} }
if (result instanceof RSVP.Queue) { if (result instanceof RSVP.Queue) {
return result; return result;
} }
return new RSVP.Queue() return new RSVP.Queue(result);
.push(function returnPushableResult() {
return result;
});
} }
function readBlobAsDataURL(blob) { function readBlobAsDataURL(blob) {
...@@ -829,20 +823,10 @@ if (typeof document.contains !== 'function') { ...@@ -829,20 +823,10 @@ if (typeof document.contains !== 'function') {
try { try {
result = callback(evt); result = callback(evt);
} catch (e) { } catch (e) {
result = RSVP.reject(e); return reject(e);
} }
callback_promise = result; callback_promise = new RSVP.Queue(result).push(undefined, reject);
new RSVP.Queue()
.push(function waitForEventCallbackResult() {
return result;
})
.push(undefined, function handleEventCallbackError(error) {
if (!(error instanceof RSVP.CancellationError)) {
canceller();
reject(error);
}
});
}; };
target.addEventListener(type, handle_event_callback, useCapture); target.addEventListener(type, handle_event_callback, useCapture);
...@@ -1141,10 +1125,7 @@ if (typeof document.contains !== 'function') { ...@@ -1141,10 +1125,7 @@ if (typeof document.contains !== 'function') {
if (resolved) { if (resolved) {
throw new ResolvedMonitorError(); throw new ResolvedMonitorError();
} }
var queue = new RSVP.Queue() var queue = new RSVP.Queue(promise_to_monitor)
.push(function waitForPromiseToMonitor() {
return promise_to_monitor;
})
.push(function handlePromiseToMonitorSuccess(fulfillmentValue) { .push(function handlePromiseToMonitorSuccess(fulfillmentValue) {
// Promise to monitor is fullfilled, remove it from the list // Promise to monitor is fullfilled, remove it from the list
var len = promise_list.length, var len = promise_list.length,
...@@ -1160,13 +1141,6 @@ if (typeof document.contains !== 'function') { ...@@ -1160,13 +1141,6 @@ if (typeof document.contains !== 'function') {
} }
promise_list = new_promise_list; promise_list = new_promise_list;
}, function handlePromiseToMonitorError(rejectedReason) { }, function handlePromiseToMonitorError(rejectedReason) {
if (rejectedReason instanceof RSVP.CancellationError) {
if (!(promise_to_monitor.isFulfilled &&
promise_to_monitor.isRejected)) {
// The queue could be cancelled before the first push is run
promise_to_monitor.cancel();
}
}
reject(rejectedReason); reject(rejectedReason);
throw rejectedReason; throw rejectedReason;
}); });
...@@ -1321,16 +1295,16 @@ if (typeof document.contains !== 'function') { ...@@ -1321,16 +1295,16 @@ if (typeof document.contains !== 'function') {
}; };
function runJob(gadget, name, callback, argument_list) { function runJob(gadget, name, callback, argument_list) {
var job_promise = ensurePushableQueue(callback, argument_list, gadget);
if (gadget.__job_dict.hasOwnProperty(name)) { if (gadget.__job_dict.hasOwnProperty(name)) {
gadget.__job_dict[name].cancel(); gadget.__job_dict[name].cancel();
} }
var job_promise = ensurePushableQueue(callback, argument_list, gadget);
gadget.__job_dict[name] = job_promise; gadget.__job_dict[name] = job_promise;
gadget.__monitor.monitor(new RSVP.Queue() // gadget.__monitor.monitor(job_promise
.push(function waitForJobPromise() { gadget.__monitor.monitor(new RSVP.Queue(job_promise)
return job_promise;
})
.push(undefined, function handleJobError(error) { .push(undefined, function handleJobError(error) {
// Do not crash monitor if the job has been cancelled
// by a new execution
if (!(error instanceof RSVP.CancellationError)) { if (!(error instanceof RSVP.CancellationError)) {
throw error; throw error;
} }
...@@ -1918,10 +1892,7 @@ if (typeof document.contains !== 'function') { ...@@ -1918,10 +1892,7 @@ if (typeof document.contains !== 'function') {
result = method(url, options, parent_gadget, old_element); result = method(url, options, parent_gadget, old_element);
// Set the HTML context // Set the HTML context
if (typeof result.then === 'function') { if (typeof result.then === 'function') {
return new RSVP.Queue() return new RSVP.Queue(result)
.push(function () {
return result;
})
.push(function setAsyncGadgetInstanceHTMLContext(gadget_instance) { .push(function setAsyncGadgetInstanceHTMLContext(gadget_instance) {
return setGadgetInstanceHTMLContext(gadget_instance, options, return setGadgetInstanceHTMLContext(gadget_instance, options,
parent_gadget, url, parent_gadget, url,
...@@ -2641,11 +2612,8 @@ if (typeof document.contains !== 'function') { ...@@ -2641,11 +2612,8 @@ if (typeof document.contains !== 'function') {
embedded_channel, embedded_channel,
declare_method_list_waiting; declare_method_list_waiting;
return new RSVP.Queue() // Wait for the loading gadget to be created
.push(function waitForLoadingGadget() { return new RSVP.Queue(wait_for_gadget_loaded)
// Wait for the loading gadget to be created
return wait_for_gadget_loaded;
})
.push(function handleLoadingGadget(result_list) { .push(function handleLoadingGadget(result_list) {
TmpConstructor = result_list[0]; TmpConstructor = result_list[0];
root_gadget = result_list[1]; root_gadget = result_list[1];
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>981.31793.23133.50602</string> </value> <value> <string>982.6529.44506.21401</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1580395066.9</float> <float>1582798736.54</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -763,18 +763,12 @@ if (typeof document.contains !== 'function') { ...@@ -763,18 +763,12 @@ if (typeof document.contains !== 'function') {
try { try {
result = callback.apply(context, argument_list); result = callback.apply(context, argument_list);
} catch (e) { } catch (e) {
return new RSVP.Queue() return new RSVP.Queue(RSVP.reject(e));
.push(function returnPushableError() {
return RSVP.reject(e);
});
} }
if (result instanceof RSVP.Queue) { if (result instanceof RSVP.Queue) {
return result; return result;
} }
return new RSVP.Queue() return new RSVP.Queue(result);
.push(function returnPushableResult() {
return result;
});
} }
function readBlobAsDataURL(blob) { function readBlobAsDataURL(blob) {
...@@ -829,20 +823,10 @@ if (typeof document.contains !== 'function') { ...@@ -829,20 +823,10 @@ if (typeof document.contains !== 'function') {
try { try {
result = callback(evt); result = callback(evt);
} catch (e) { } catch (e) {
result = RSVP.reject(e); return reject(e);
} }
callback_promise = result; callback_promise = new RSVP.Queue(result).push(undefined, reject);
new RSVP.Queue()
.push(function waitForEventCallbackResult() {
return result;
})
.push(undefined, function handleEventCallbackError(error) {
if (!(error instanceof RSVP.CancellationError)) {
canceller();
reject(error);
}
});
}; };
target.addEventListener(type, handle_event_callback, useCapture); target.addEventListener(type, handle_event_callback, useCapture);
...@@ -1141,10 +1125,7 @@ if (typeof document.contains !== 'function') { ...@@ -1141,10 +1125,7 @@ if (typeof document.contains !== 'function') {
if (resolved) { if (resolved) {
throw new ResolvedMonitorError(); throw new ResolvedMonitorError();
} }
var queue = new RSVP.Queue() var queue = new RSVP.Queue(promise_to_monitor)
.push(function waitForPromiseToMonitor() {
return promise_to_monitor;
})
.push(function handlePromiseToMonitorSuccess(fulfillmentValue) { .push(function handlePromiseToMonitorSuccess(fulfillmentValue) {
// Promise to monitor is fullfilled, remove it from the list // Promise to monitor is fullfilled, remove it from the list
var len = promise_list.length, var len = promise_list.length,
...@@ -1160,13 +1141,6 @@ if (typeof document.contains !== 'function') { ...@@ -1160,13 +1141,6 @@ if (typeof document.contains !== 'function') {
} }
promise_list = new_promise_list; promise_list = new_promise_list;
}, function handlePromiseToMonitorError(rejectedReason) { }, function handlePromiseToMonitorError(rejectedReason) {
if (rejectedReason instanceof RSVP.CancellationError) {
if (!(promise_to_monitor.isFulfilled &&
promise_to_monitor.isRejected)) {
// The queue could be cancelled before the first push is run
promise_to_monitor.cancel();
}
}
reject(rejectedReason); reject(rejectedReason);
throw rejectedReason; throw rejectedReason;
}); });
...@@ -1321,16 +1295,16 @@ if (typeof document.contains !== 'function') { ...@@ -1321,16 +1295,16 @@ if (typeof document.contains !== 'function') {
}; };
function runJob(gadget, name, callback, argument_list) { function runJob(gadget, name, callback, argument_list) {
var job_promise = ensurePushableQueue(callback, argument_list, gadget);
if (gadget.__job_dict.hasOwnProperty(name)) { if (gadget.__job_dict.hasOwnProperty(name)) {
gadget.__job_dict[name].cancel(); gadget.__job_dict[name].cancel();
} }
var job_promise = ensurePushableQueue(callback, argument_list, gadget);
gadget.__job_dict[name] = job_promise; gadget.__job_dict[name] = job_promise;
gadget.__monitor.monitor(new RSVP.Queue() // gadget.__monitor.monitor(job_promise
.push(function waitForJobPromise() { gadget.__monitor.monitor(new RSVP.Queue(job_promise)
return job_promise;
})
.push(undefined, function handleJobError(error) { .push(undefined, function handleJobError(error) {
// Do not crash monitor if the job has been cancelled
// by a new execution
if (!(error instanceof RSVP.CancellationError)) { if (!(error instanceof RSVP.CancellationError)) {
throw error; throw error;
} }
...@@ -1918,10 +1892,7 @@ if (typeof document.contains !== 'function') { ...@@ -1918,10 +1892,7 @@ if (typeof document.contains !== 'function') {
result = method(url, options, parent_gadget, old_element); result = method(url, options, parent_gadget, old_element);
// Set the HTML context // Set the HTML context
if (typeof result.then === 'function') { if (typeof result.then === 'function') {
return new RSVP.Queue() return new RSVP.Queue(result)
.push(function () {
return result;
})
.push(function setAsyncGadgetInstanceHTMLContext(gadget_instance) { .push(function setAsyncGadgetInstanceHTMLContext(gadget_instance) {
return setGadgetInstanceHTMLContext(gadget_instance, options, return setGadgetInstanceHTMLContext(gadget_instance, options,
parent_gadget, url, parent_gadget, url,
...@@ -2641,11 +2612,8 @@ if (typeof document.contains !== 'function') { ...@@ -2641,11 +2612,8 @@ if (typeof document.contains !== 'function') {
embedded_channel, embedded_channel,
declare_method_list_waiting; declare_method_list_waiting;
return new RSVP.Queue() // Wait for the loading gadget to be created
.push(function waitForLoadingGadget() { return new RSVP.Queue(wait_for_gadget_loaded)
// Wait for the loading gadget to be created
return wait_for_gadget_loaded;
})
.push(function handleLoadingGadget(result_list) { .push(function handleLoadingGadget(result_list) {
TmpConstructor = result_list[0]; TmpConstructor = result_list[0];
root_gadget = result_list[1]; root_gadget = result_list[1];
......
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