Commit 8bb6f285 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: rjs 0.22

parent 3bea5dc5
......@@ -2103,7 +2103,8 @@ if (typeof document.contains !== 'function') {
(new DOMParser()).parseFromString(xhr.responseText, "text/html");
parsed_html = renderJS.parseGadgetHTMLDocument(
tmp_constructor.__template_element,
url
url,
true
);
for (key in parsed_html) {
if (parsed_html.hasOwnProperty(key)) {
......@@ -2208,7 +2209,8 @@ if (typeof document.contains !== 'function') {
// renderJS.parseGadgetHTMLDocument
/////////////////////////////////////////////////////////////////
renderJS.parseGadgetHTMLDocument =
function parseGadgetHTMLDocument(document_element, url) {
function parseGadgetHTMLDocument(document_element, url,
update_relative_url) {
var settings = {
title: "",
interface_list: [],
......@@ -2218,12 +2220,20 @@ if (typeof document.contains !== 'function') {
},
i,
element,
element_list,
j,
url_attribute_list = ['src', 'href', 'srcset'],
url_attribute,
base_found = false;
if (!url || !isAbsoluteOrDataURL.test(url)) {
throw new Error("The url should be absolute: " + url);
}
if (update_relative_url === undefined) {
update_relative_url = false;
}
if (document_element.nodeType === 9) {
settings.title = document_element.title;
......@@ -2264,6 +2274,25 @@ if (typeof document.contains !== 'function') {
}
}
}
if (update_relative_url && (document_element.body !== null)) {
// Resolve all relativeurl configure in the dom as absolute from
// the gadget url
for (j = 0; j < url_attribute_list.length; j += 1) {
url_attribute = url_attribute_list[j];
element_list = document_element.body.querySelectorAll(
'[' + url_attribute + ']'
);
for (i = 0; i < element_list.length; i += 1) {
element = element_list[i];
element.setAttribute(url_attribute, renderJS.getAbsoluteURL(
element.getAttribute(url_attribute),
settings.path
));
}
}
}
} else {
throw new Error("The first parameter should be an HTMLDocument");
}
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>981.31790.42144.14216</string> </value>
<value> <string>981.31793.23133.50602</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1580297361.1</float>
<float>1580395066.9</float>
<string>UTC</string>
</tuple>
</state>
......
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