From 0d4f418b61f632ccd106fbf9052383e3fdec538c Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Fri, 16 Oct 2015 17:27:51 -0700 Subject: [PATCH] Fix #2587: When Polymer.dom(el).appendChild(node) is called, cleanup work must be performed on the existing parent of node. This change fixes a missing case in this cleanup work: if the existing parent has a observer via `Polymer.dom(parent).observeNodes`, it needs to be notified that node is being removed even if the node does not have specific logical info. For example, if an observed node has no Shady DOM and has a child that is removed. A test for this case was added. --- src/lib/dom-api.html | 4 +- test/smoke/observeNodes-repeat.html | 108 ++++++++++++++++++++++++ test/unit/polymer-dom-observeNodes.html | 34 ++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 test/smoke/observeNodes-repeat.html diff --git a/src/lib/dom-api.html b/src/lib/dom-api.html index 9a7b43fea4..ebde2403b4 100644 --- a/src/lib/dom-api.html +++ b/src/lib/dom-api.html @@ -274,7 +274,9 @@ }, _removeNodeFromParent: function(node) { - var parent = node._lightParent; + // note: we may need to notify and not have logical info so fallback + // to composed parentNode. + var parent = node._lightParent || node.parentNode; if (parent && hasDomApi(parent)) { factory(parent).notifyObserver(); } diff --git a/test/smoke/observeNodes-repeat.html b/test/smoke/observeNodes-repeat.html new file mode 100644 index 0000000000..a578158758 --- /dev/null +++ b/test/smoke/observeNodes-repeat.html @@ -0,0 +1,108 @@ + + + + + observeNodes-repeat + + + + + + + + + + + + + + + diff --git a/test/unit/polymer-dom-observeNodes.html b/test/unit/polymer-dom-observeNodes.html index 9643fd635e..e1e0d28816 100644 --- a/test/unit/polymer-dom-observeNodes.html +++ b/test/unit/polymer-dom-observeNodes.html @@ -165,6 +165,8 @@
static A
static B
+
+