diff --git a/src/lib/dom-tree-api.html b/src/lib/dom-tree-api.html
index 296b6f579e..2195423611 100644
--- a/src/lib/dom-tree-api.html
+++ b/src/lib/dom-tree-api.html
@@ -195,7 +195,11 @@
// the act of setting this info can affect patched nodes
// getters; therefore capture childNodes before patching.
for (var n=node.firstChild; n; n=n.nextSibling) {
- this._linkNode(n, container, ref_node);
+ // only link in the child iff it's not already in the container's
+ // logical tree.
+ if (this.getParentNode(n) !== container) {
+ this._linkNode(n, container, ref_node);
+ }
}
} else {
this._linkNode(node, container, ref_node);
diff --git a/src/lib/template/dom-repeat.html b/src/lib/template/dom-repeat.html
index 3ab89abea8..04ec5c3788 100644
--- a/src/lib/template/dom-repeat.html
+++ b/src/lib/template/dom-repeat.html
@@ -254,15 +254,20 @@
},
detached: function() {
+ this.__isDetached = true;
for (var i=0; i
+
+
+
+ distribute dom-repeat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.id}}
+
+
+
+
+
+
+
+
+
+
diff --git a/test/unit/polymer-dom-content.html b/test/unit/polymer-dom-content.html
index be6f99aa33..45b59afba7 100644
--- a/test/unit/polymer-dom-content.html
+++ b/test/unit/polymer-dom-content.html
@@ -40,6 +40,11 @@
+
+
+
+
+
x-dist-inside-deep-tree
@@ -243,6 +248,31 @@
+
+
+
+
+ {{item}}
+
+
+
+
+
+
+
+
Child
@@ -1396,8 +1426,23 @@
Polymer.dom(document.body).removeChild(div);
});
+ test('dom-repeat that distributes inside a select=* container', function(done) {
+ var x1 = document.querySelector('#repeat2');
+ Polymer.dom.flush();
+ // async due to attachment.
+ setTimeout(function() {
+ assert.equal(Polymer.dom(x1.$.dist).children.length, 4);
+ if (x1.$.dist.shadyRoot) {
+ assert.equal(x1.$.dist.children.length, 4);
+ }
+ done();
+ });
+ });
+
});
+
+
suite('multi-content mutations', function() {
test('remove, append first content', function() {