diff --git a/src/lib/template/dom-if.html b/src/lib/template/dom-if.html
index 56ab20a36c..f1852c0b77 100644
--- a/src/lib/template/dom-if.html
+++ b/src/lib/template/dom-if.html
@@ -116,12 +116,16 @@
_ensureInstance: function() {
if (!this._instance) {
- // TODO(sorvell): pickup stamping logic from x-repeat
- this._instance = this.stamp();
- var root = this._instance.root;
- // TODO(sorvell): this incantation needs to be simpler.
- var parent = Polymer.dom(Polymer.dom(this).parentNode);
- parent.insertBefore(root, this);
+ var parentNode = Polymer.dom(this).parentNode;
+ // Guard against element being detached while render was queued
+ if (parentNode) {
+ var parent = Polymer.dom(parentNode);
+ // TODO(sorvell): pickup stamping logic from x-repeat
+ this._instance = this.stamp();
+ var root = this._instance.root;
+ // TODO(sorvell): this incantation needs to be simpler.
+ parent.insertBefore(root, this);
+ }
}
},
diff --git a/test/unit/dom-if.html b/test/unit/dom-if.html
index c1e46d6972..12b0c05a31 100644
--- a/test/unit/dom-if.html
+++ b/test/unit/dom-if.html
@@ -56,6 +56,12 @@
+
+
+
+
+
+