From 8df574c68a23efb184df2d30c88e841e9655eafc Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Tue, 8 Oct 2013 15:02:52 -0700 Subject: [PATCH] Don't crash on template destroyed callback --- packages/ui/base.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/ui/base.js b/packages/ui/base.js index 3bb8fb4e67..f0132c90fc 100644 --- a/packages/ui/base.js +++ b/packages/ui/base.js @@ -1156,13 +1156,13 @@ updateTemplateInstance = function (comp) { var tmpl = comp.templateInstance; tmpl.data = getComponentData(comp); - if (comp.dom) { + if (comp.dom && !comp.isDestroyed) { 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) + if (tmpl.lastNode && tmpl.lastNode.nextSibling === tmpl.firstNode) tmpl.lastNode = tmpl.firstNode; } else { // on 'created' or 'destroyed' callbacks we don't have a DomRange @@ -1234,6 +1234,7 @@ UI.Component.parented = function () { // XXX UI.Component.removed = function () { var self = this; + self.isDestroyed = true; if (self.destroyed) { updateTemplateInstance(self); self.destroyed.call(self.templateInstance);