diff --git a/src/lib/template/dom-if.html b/src/lib/template/dom-if.html index 9d699a22c7..c06ddef99f 100644 --- a/src/lib/template/dom-if.html +++ b/src/lib/template/dom-if.html @@ -135,17 +135,17 @@ }, _ensureInstance: function() { + var refNode; var parentNode = Polymer.dom(this).parentNode; + // Affordance for 2.x hybrid mode + if (parentNode && parentNode.localName == this.is) { + refNode = parentNode; + parentNode = Polymer.dom(parentNode).parentNode; + } else { + refNode = this; + } // Guard against element being detached while render was queued if (parentNode) { - var refNode; - // Affordance for 2.x hybrid mode - if (parentNode.localName == this.is) { - refNode = parentNode; - parentNode = Polymer.dom(parentNode).parentNode; - } else { - refNode = this; - } if (!this._instance) { this._instance = this.stamp(); var root = this._instance.root; @@ -154,7 +154,7 @@ var c$ = this._instance._children; if (c$ && c$.length) { // Detect case where dom-if was re-attached in new position - var lastChild = Polymer.dom(this).previousSibling; + var lastChild = Polymer.dom(refNode).previousSibling; if (lastChild !== c$[c$.length-1]) { for (var i=0, n; (i