From 01fd48cb884ca5c9c59136ffae4358f49680a34f Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Wed, 18 Sep 2013 13:51:04 -0700 Subject: [PATCH] unbreak created and destroyed callbacks there is no DomRange available then, so don't set firstNode and lastNode on the template instance --- packages/ui/base.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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, {