fix(ivy): correctly handle queries with embedded views (#24418)

This PR takes care of all the remaining cases where embedded view definition
and insertion points are different.

PR Close #24418
This commit is contained in:
Pawel Kozlowski
2018-06-11 11:51:16 +02:00
committed by Miško Hevery
parent 5e8bf2f88d
commit 014949f74c
4 changed files with 87 additions and 12 deletions

View File

@ -49,7 +49,7 @@ export interface LQueries {
* Notify `LQueries` that an `LView` has been removed from `LContainer`. As a result all
* the matching nodes from this view should be removed from container's queries.
*/
removeView(removeIndex: number): void;
removeView(): void;
/**
* Add additional `QueryList` to track.

View File

@ -393,7 +393,7 @@ export function detachView(container: LContainerNode, removeIndex: number): LVie
// Notify query that view has been removed
const removedLview = viewNode.data;
if (removedLview[QUERIES]) {
removedLview[QUERIES] !.removeView(removeIndex);
removedLview[QUERIES] !.removeView();
}
// Unsets the attached flag
viewNode.data[FLAGS] &= ~LViewFlags.Attached;

View File

@ -176,13 +176,16 @@ export class LQueries_ implements LQueries {
add(this.deep, node);
}
removeView(index: number): void {
removeView(): void {
let query = this.deep;
while (query) {
ngDevMode &&
assertDefined(
query.containerValues, 'View queries need to have a pointer to container values.');
const removed = query.containerValues !.splice(index, 1);
const containerValues = query.containerValues !;
const viewValuesIdx = containerValues.indexOf(query.values);
const removed = containerValues.splice(viewValuesIdx, 1);
// mark a query as dirty only when removed view had matching modes
ngDevMode && assertEqual(removed.length, 1, 'removed.length');