Skip to content

Commit

Permalink
Polymer.dom: when adding a node, only remove the node from its existi…
Browse files Browse the repository at this point in the history
…ng location if it's not a fragment and has a parent.
  • Loading branch information
Steven Orvell committed Dec 10, 2015
1 parent 5033fdb commit 9915627
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/lib/dom-api-shady.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@
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
Expand Down

0 comments on commit 9915627

Please sign in to comment.