fix(content_projection): allow to project text nodes to a place without bindings

Fixes #3163
Closes #3179
This commit is contained in:
Tobias Bosch
2015-07-21 10:43:02 -07:00
parent 078475a082
commit a472eacc07
2 changed files with 19 additions and 0 deletions

View File

@ -27,6 +27,9 @@ export function mergeProtoViewsRecursively(protoViewRefs: List<RenderProtoViewRe
mergeEmbeddedPvsIntoComponentOrRootPv(clonedProtoViews, hostViewAndBinderIndices);
var fragments = [];
mergeComponents(clonedProtoViews, hostViewAndBinderIndices, fragments);
// Note: Need to remark parent elements of bound text nodes
// so that we can find them later via queryBoundElements!
markBoundTextNodeParentsAsBoundElements(clonedProtoViews);
// create a new root element with the changed fragments and elements
var rootElement = createRootElementFromFragments(fragments);
@ -86,6 +89,17 @@ function cloneProtoViews(protoViewRefs: List<RenderProtoViewRef | List<any>>,
}
}
function markBoundTextNodeParentsAsBoundElements(mergableProtoViews: ClonedProtoView[]) {
mergableProtoViews.forEach((mergableProtoView) => {
mergableProtoView.boundTextNodes.forEach((textNode) => {
var parentNode = textNode.parentNode;
if (isPresent(parentNode) && DOM.isElementNode(parentNode)) {
DOM.addClass(parentNode, NG_BINDING_CLASS);
}
});
});
}
function indexBoundTextNodes(mergableProtoViews: ClonedProtoView[]): Map<Node, any> {
var boundTextNodeMap = new Map();
for (var pvIndex = 0; pvIndex < mergableProtoViews.length; pvIndex++) {