diff --git a/packages/ui/base.js b/packages/ui/base.js index 0f41776626..24779cc4d2 100644 --- a/packages/ui/base.js +++ b/packages/ui/base.js @@ -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, {