mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Simplify fix for fragment children management.
This commit is contained in:
parent
25da63d132
commit
713377ead8
@ -56,8 +56,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
'of this node');
|
||||
}
|
||||
// remove node from its current position iff it's in a tree.
|
||||
var isFragment = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
|
||||
if (!isFragment) {
|
||||
if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
|
||||
var parent = TreeApi.Logical.getParentNode(node);
|
||||
// notify existing parent that this node is being removed.
|
||||
if (parent) {
|
||||
@ -82,11 +81,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
} else {
|
||||
TreeApi.Composed.appendChild(container, node);
|
||||
}
|
||||
// if a fragment provoked distribution, clean up it's actual dom.
|
||||
} else if (isFragment) {
|
||||
while (node.firstChild) {
|
||||
node.removeChild(node.firstChild);
|
||||
}
|
||||
}
|
||||
this.notifyObserver();
|
||||
return node;
|
||||
@ -105,8 +99,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
TreeApi.Logical.recordInsertBefore(node, this.node, ref_node);
|
||||
}
|
||||
// if not distributing and not adding to host, do a fast path addition
|
||||
return (this._maybeDistribute(node) ||
|
||||
var handled = (this._maybeDistribute(node) ||
|
||||
this._tryRemoveUndistributedNode(node));
|
||||
// if distribution is handling this node and it's a fragment,
|
||||
// the actual dom may not be removed from the fragment if some nodes
|
||||
// remain undistributed so we ensure removal here.
|
||||
if (handled && (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE)) {
|
||||
while (node.firstChild) {
|
||||
node.removeChild(node.firstChild);
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -195,12 +195,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// 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) {
|
||||
// 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user