Skip to content

Commit

Permalink
Ensure optimization uses hybrid parentNode
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Apr 17, 2017
1 parent 2e4290f commit b7f0099
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/lib/template/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<c$.length) && (n=c$[i]); i++) {
Polymer.dom(parentNode).insertBefore(n, refNode);
Expand Down

0 comments on commit b7f0099

Please sign in to comment.