From 9f2464df6942eed45170291d99a19858f2d822ff Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Fri, 22 Jan 2016 16:07:39 -0800 Subject: [PATCH] Fixes #3321. Only let dom-repeat insert elements in attached if it has been previously detached; correctly avoid re-adding children in document fragments to an element's logical linked list if they are already there. --- src/lib/dom-tree-api.html | 6 ++- src/lib/template/dom-repeat.html | 11 +++-- test/smoke/distribute-dom-repeat.html | 62 +++++++++++++++++++++++++++ test/unit/polymer-dom-content.html | 45 +++++++++++++++++++ 4 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 test/smoke/distribute-dom-repeat.html 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 + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + +