Commit 098c272c authored by Romain Courteaud's avatar Romain Courteaud

Use document fragment to aggregate DOM element.

parent 8c2ac0cc
...@@ -733,15 +733,17 @@ ...@@ -733,15 +733,17 @@
} }
var i, var i,
gadget_instance, gadget_instance,
template_node_list = Klass.__template_element.body.childNodes; template_node_list = Klass.__template_element.body.childNodes,
fragment = document.createDocumentFragment();
gadget_instance = new Klass(); gadget_instance = new Klass();
gadget_instance.element = options.element; gadget_instance.element = options.element;
gadget_instance.state = {}; gadget_instance.state = {};
for (i = 0; i < template_node_list.length; i += 1) { for (i = 0; i < template_node_list.length; i += 1) {
gadget_instance.element.appendChild( fragment.appendChild(
template_node_list[i].cloneNode(true) template_node_list[i].cloneNode(true)
); );
} }
gadget_instance.element.appendChild(fragment);
setAqParent(gadget_instance, parent_gadget); setAqParent(gadget_instance, parent_gadget);
return gadget_instance; return gadget_instance;
}); });
...@@ -1496,7 +1498,8 @@ ...@@ -1496,7 +1498,8 @@
// XXX HTML properties can only be set when the DOM is fully loaded // XXX HTML properties can only be set when the DOM is fully loaded
var settings = renderJS.parseGadgetHTMLDocument(document, url), var settings = renderJS.parseGadgetHTMLDocument(document, url),
j, j,
key; key,
fragment = document.createDocumentFragment();
for (key in settings) { for (key in settings) {
if (settings.hasOwnProperty(key)) { if (settings.hasOwnProperty(key)) {
TmpConstructor.prototype['__' + key] = settings[key]; TmpConstructor.prototype['__' + key] = settings[key];
...@@ -1506,10 +1509,11 @@ ...@@ -1506,10 +1509,11 @@
root_gadget.element = document.body; root_gadget.element = document.body;
root_gadget.state = {}; root_gadget.state = {};
for (j = 0; j < root_gadget.element.childNodes.length; j += 1) { for (j = 0; j < root_gadget.element.childNodes.length; j += 1) {
TmpConstructor.__template_element.appendChild( fragment.appendChild(
root_gadget.element.childNodes[j].cloneNode(true) root_gadget.element.childNodes[j].cloneNode(true)
); );
} }
TmpConstructor.__template_element.appendChild(fragment);
RSVP.all([root_gadget.getRequiredJSList(), RSVP.all([root_gadget.getRequiredJSList(),
root_gadget.getRequiredCSSList()]) root_gadget.getRequiredCSSList()])
.then(function (all_list) { .then(function (all_list) {
......
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