diff --git a/src/lib/template/dom-bind.html b/src/lib/template/dom-bind.html
index c9561c9105..a7cdf4bccd 100644
--- a/src/lib/template/dom-bind.html
+++ b/src/lib/template/dom-bind.html
@@ -108,8 +108,16 @@
},
_insertChildren: function() {
- var parentDom = Polymer.dom(Polymer.dom(this).parentNode);
- parentDom.insertBefore(this.root, this);
+ var refNode;
+ var parentNode = Polymer.dom(this).parentNode;
+ // Affordance for 2.x hybrid mode
+ if (parentNode.localName == this.is) {
+ refNode = parentNode;
+ parentNode = Polymer.dom(parentNode).parentNode;
+ } else {
+ refNode = this;
+ }
+ Polymer.dom(parentNode).insertBefore(this.root, refNode);
},
_removeChildren: function() {
diff --git a/src/lib/template/dom-if.html b/src/lib/template/dom-if.html
index dc018ba579..c06ddef99f 100644
--- a/src/lib/template/dom-if.html
+++ b/src/lib/template/dom-if.html
@@ -82,10 +82,14 @@
},
detached: function() {
- if (!this.parentNode ||
- (this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE &&
+ var parentNode = this.parentNode;
+ if (parentNode && parentNode.localName == this.is) {
+ parentNode = Polymer.dom(parentNode).parentNode;
+ }
+ if (!parentNode ||
+ (parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE &&
(!Polymer.Settings.hasShadow ||
- !(this.parentNode instanceof ShadowRoot)))) {
+ !(parentNode instanceof ShadowRoot)))) {
this._teardownInstance();
}
},
@@ -131,22 +135,29 @@
},
_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 parent = Polymer.dom(parentNode);
if (!this._instance) {
this._instance = this.stamp();
var root = this._instance.root;
- parent.insertBefore(root, this);
+ Polymer.dom(parentNode).insertBefore(root, refNode);
} else {
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
@@ -42,6 +42,13 @@
+
+
+
+
+
+
+
diff --git a/test/unit/dom-if.html b/test/unit/dom-if.html
index 39dfcfbf14..33e8d80e21 100644
--- a/test/unit/dom-if.html
+++ b/test/unit/dom-if.html
@@ -71,8 +71,51 @@
+
+
+
+ [[prop]]
+
+
+