unbreak created and destroyed callbacks

there is no DomRange available then, so don't
set firstNode and lastNode on the template instance
This commit is contained in:
Avital Oliver
2013-09-18 13:51:04 -07:00
parent 665cfb269d
commit 01fd48cb88

View File

@@ -1145,13 +1145,20 @@ updateTemplateInstance = function (comp) {
// on demand.
var tmpl = comp.templateInstance;
tmpl.data = getComponentData(comp);
tmpl.firstNode = comp.dom.startNode().nextSibling;
tmpl.lastNode = comp.dom.endNode().previousSibling;
// Catch the case where the DomRange is empty and we'd
// otherwise pass the out-of-order nodes (end, start)
// as (firstNode, lastNode).
if (tmpl.lastNode.nextSibling === tmpl.firstNode)
tmpl.lastNode = tmpl.firstNode;
if (comp.dom) {
tmpl.firstNode = comp.dom.startNode().nextSibling;
tmpl.lastNode = comp.dom.endNode().previousSibling;
// Catch the case where the DomRange is empty and we'd
// otherwise pass the out-of-order nodes (end, start)
// as (firstNode, lastNode).
if (tmpl.lastNode.nextSibling === tmpl.firstNode)
tmpl.lastNode = tmpl.firstNode;
} else {
// on 'created' or 'destroyed' callbacks we don't have a DomRange
tmpl.firstNode = null;
tmpl.lastNode = null;
}
};
_extend(UI.Component, {