Polymer.dom: when adding a node, only remove the node from its existing location if it's not a fragment and has a parent.

This commit is contained in:
Steven Orvell 2015-12-09 17:55:14 -08:00
parent 5033fdb29c
commit 9915627e30

View File

@ -55,12 +55,19 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
throw Error('The ref_node to be inserted before is not a child ' +
'of this node');
}
// notify existing parent that this node is being removed.
var parent = TreeApi.Logical.getParentNode(node);
if (parent && DomApi.hasApi(parent)) {
dom(parent).notifyObserver();
// remove node from its current position iff it's in a tree.
if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
var parent = TreeApi.Logical.getParentNode(node);
// notify existing parent that this node is being removed.
if (parent) {
if (DomApi.hasApi(parent)) {
dom(parent).notifyObserver();
}
this._removeNode(node);
} else {
this._removeOwnerShadyRoot(node);
}
}
this._removeNode(node);
if (!this._addNode(node, ref_node)) {
if (ref_node) {
// if ref_node is <content> replace with first distributed node