Commit 67513d6c authored by Romain Courteaud's avatar Romain Courteaud Committed by Jérome Perrin

Speed up page modification.

If possible, do not use innerHTML.
parent dff6f358
...@@ -165,8 +165,6 @@ ...@@ -165,8 +165,6 @@
return gadget.aq_pleasePublishMyState({page: "document_list"}) return gadget.aq_pleasePublishMyState({page: "document_list"})
.push(gadget.pleaseRedirectMyHash.bind(gadget)); .push(gadget.pleaseRedirectMyHash.bind(gadget));
} }
// Clear the previous rendering
element.innerHTML = "";
return gadget.declareGadget(options.page + ".html") return gadget.declareGadget(options.page + ".html")
.push(function (g) { .push(function (g) {
page_gadget = g; page_gadget = g;
...@@ -191,17 +189,24 @@ ...@@ -191,17 +189,24 @@
gadget.props.element.querySelector("header h1").textContent = gadget.props.element.querySelector("header h1").textContent =
title; title;
// Append in the DOM at the end to reduce flickering and reduce DOM
// modifications
element.appendChild(page_element);
while (panel.firstChild) {
panel.removeChild(panel.firstChild);
}
panel.innerHTML = panel.innerHTML =
navigation_template({navigationlist: navigation_list}); navigation_template({navigationlist: navigation_list});
// XXX JQuery mobile // XXX JQuery mobile
$(element).trigger('create');
$(panel).trigger("create"); $(panel).trigger("create");
// Append in the DOM at the end to reduce flickering and reduce DOM
// modifications
// Clear the previous rendering
while (element.firstChild) {
element.removeChild(element.firstChild);
}
element.appendChild(page_element);
$(element).trigger('create');
// XXX RenderJS hack to start sub gadget services // XXX RenderJS hack to start sub gadget services
// Only work if this gadget has no parent. // Only work if this gadget has no parent.
if (page_gadget.startService !== undefined) { if (page_gadget.startService !== undefined) {
......
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