fix(ivy): fix issue with refreshing embedded views (#23164)

PR Close #23164
This commit is contained in:
Pawel Kozlowski 2018-04-04 14:40:06 +02:00 committed by Igor Minar
parent 3b607e60e9
commit fc813f67f4
2 changed files with 11 additions and 2 deletions

View File

@ -442,6 +442,7 @@ export function renderEmbeddedTemplate<T>(
renderer: Renderer3): LViewNode {
const _isParent = isParent;
const _previousOrParentNode = previousOrParentNode;
let oldView: LView;
try {
isParent = true;
previousOrParentNode = null !;
@ -456,14 +457,14 @@ export function renderEmbeddedTemplate<T>(
viewNode = createLNode(null, LNodeType.View, null, view);
cm = true;
}
enterView(viewNode.data, viewNode);
oldView = enterView(viewNode.data, viewNode);
template(context, cm);
refreshDirectives();
refreshDynamicChildren();
} finally {
leaveView(currentView && currentView !.parent !);
leaveView(oldView !);
isParent = _isParent;
previousOrParentNode = _previousOrParentNode;
}

View File

@ -119,6 +119,10 @@ describe('ViewContainerRef', () => {
directiveInstance !.insertTpl();
expect(fixture.html).toEqual('before<div testdir=""></div>From a template.after');
// run change-detection cycle with no template insertion / removal
fixture.update();
expect(fixture.html).toEqual('before<div testdir=""></div>From a template.after');
directiveInstance !.insertTpl();
expect(fixture.html)
.toEqual('before<div testdir=""></div>From a template.From a template.after');
@ -178,6 +182,10 @@ describe('ViewContainerRef', () => {
directiveInstance !.insertTpl({name: 'World'});
expect(fixture.html).toEqual('before|Hello, World|after');
// run change-detection cycle with no template insertion / removal
fixture.update();
expect(fixture.html).toEqual('before|Hello, World|after');
directiveInstance !.remove(0);
expect(fixture.html).toEqual('before||after');
});