Commit 32a5a8ef authored by Romain Courteaud's avatar Romain Courteaud 🐸

Release version 0.14.0

Nearly drop iframe timeout.
Add reportGadgetDeclarationError acquired method.
parent bce5da91
This diff is collapsed.
This diff is collapsed.
...@@ -1081,19 +1081,32 @@ if (typeof document.contains !== 'function') { ...@@ -1081,19 +1081,32 @@ if (typeof document.contains !== 'function') {
}); });
} }
function clearGadgetInternalParameters(g) { function clearGadgetInternalParameters() {
g.__sub_gadget_dict = {}; this.__sub_gadget_dict = {};
createMonitor(g); createMonitor(this);
} }
function loadSubGadgetDOMDeclaration(g) { function loadSubGadgetDOMDeclaration() {
var element_list = g.element.querySelectorAll('[data-gadget-url]'), var element_list = this.element.querySelectorAll('[data-gadget-url]'),
element, element,
promise_list = [], promise_list = [],
scope, scope,
url, url,
sandbox, sandbox,
i; i,
context = this;
function prepareReportGadgetDeclarationError(scope) {
return function (error) {
var aq_dict = context.__acquired_method_dict || {},
method_name = 'reportGadgetDeclarationError';
if (aq_dict.hasOwnProperty(method_name)) {
return aq_dict[method_name].apply(context,
[arguments, scope]);
}
throw error;
};
}
for (i = 0; i < element_list.length; i += 1) { for (i = 0; i < element_list.length; i += 1) {
element = element_list[i]; element = element_list[i];
...@@ -1101,11 +1114,14 @@ if (typeof document.contains !== 'function') { ...@@ -1101,11 +1114,14 @@ if (typeof document.contains !== 'function') {
url = element.getAttribute("data-gadget-url"); url = element.getAttribute("data-gadget-url");
sandbox = element.getAttribute("data-gadget-sandbox"); sandbox = element.getAttribute("data-gadget-sandbox");
if (url !== null) { if (url !== null) {
promise_list.push(g.declareGadget(url, { promise_list.push(
element: element, context.declareGadget(url, {
scope: scope || undefined, element: element,
sandbox: sandbox || undefined scope: scope || undefined,
})); sandbox: sandbox || undefined
})
.push(undefined, prepareReportGadgetDeclarationError(scope))
);
} }
} }
...@@ -1120,9 +1136,10 @@ if (typeof document.contains !== 'function') { ...@@ -1120,9 +1136,10 @@ if (typeof document.contains !== 'function') {
}; };
RenderJSGadget.setState = function (state_dict) { RenderJSGadget.setState = function (state_dict) {
var json_state = JSON.stringify(state_dict); var json_state = JSON.stringify(state_dict);
return this.ready(function () { this.__ready_list.unshift(function () {
this.state = JSON.parse(json_state); this.state = JSON.parse(json_state);
}); });
return this;
}; };
RenderJSGadget.onStateChange = function (callback) { RenderJSGadget.onStateChange = function (callback) {
this.prototype.__state_change_callback = callback; this.prototype.__state_change_callback = callback;
...@@ -1331,6 +1348,8 @@ if (typeof document.contains !== 'function') { ...@@ -1331,6 +1348,8 @@ if (typeof document.contains !== 'function') {
}; };
RenderJSGadget.declareAcquiredMethod("aq_reportServiceError", RenderJSGadget.declareAcquiredMethod("aq_reportServiceError",
"reportServiceError"); "reportServiceError");
RenderJSGadget.declareAcquiredMethod("aq_reportGadgetDeclarationError",
"reportGadgetDeclarationError");
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// RenderJSGadget.allowPublicAcquisition // RenderJSGadget.allowPublicAcquisition
...@@ -1461,6 +1480,17 @@ if (typeof document.contains !== 'function') { ...@@ -1461,6 +1480,17 @@ if (typeof document.contains !== 'function') {
gadget_instance = new RenderJSIframeGadget(); gadget_instance = new RenderJSIframeGadget();
setAqParent(gadget_instance, parent_gadget); setAqParent(gadget_instance, parent_gadget);
iframe = document.createElement("iframe"); iframe = document.createElement("iframe");
iframe.addEventListener('error', function (error) {
iframe_loading_deferred.reject(error);
});
iframe.addEventListener('load', function () {
return RSVP.timeout(5000)
.fail(function () {
iframe_loading_deferred.reject(
new Error('Timeout while loading: ' + url)
);
});
});
// gadget_instance.element.setAttribute("seamless", "seamless"); // gadget_instance.element.setAttribute("seamless", "seamless");
iframe.setAttribute("src", url); iframe.setAttribute("src", url);
gadget_instance.__path = url; gadget_instance.__path = url;
...@@ -1524,18 +1554,7 @@ if (typeof document.contains !== 'function') { ...@@ -1524,18 +1554,7 @@ if (typeof document.contains !== 'function') {
trans.delayReturn(true); trans.delayReturn(true);
}); });
return RSVP.any([ return iframe_loading_deferred.promise;
iframe_loading_deferred.promise,
// Timeout to prevent non renderJS embeddable gadget
// XXX Maybe using iframe.onload/onerror would be safer?
new RSVP.Queue()
.push(function () {
return RSVP.timeout(5000);
})
.push(undefined, function () {
throw new Error('Timeout while loading: ' + url);
})
]);
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -2283,8 +2302,8 @@ if (typeof document.contains !== 'function') { ...@@ -2283,8 +2302,8 @@ if (typeof document.contains !== 'function') {
return fct.call(g, g); return fct.call(g, g);
}; };
} }
TmpConstructor.ready(function (g) { TmpConstructor.ready(function () {
return startService(g); return startService(this);
}); });
loading_gadget_promise.push(ready_wrapper); loading_gadget_promise.push(ready_wrapper);
......
This diff is collapsed.
{ {
"name": "renderjs", "name": "renderjs",
"version": "0.13.0", "version": "0.14.0",
"description": "RenderJs provides HTML5 gadgets", "description": "RenderJs provides HTML5 gadgets",
"main": "dist/renderjs-latest.js", "main": "dist/renderjs-latest.js",
"dependencies": { "dependencies": {
......
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