fix(ivy): fix issue with refreshing embedded views (#23164)
PR Close #23164
This commit is contained in:
parent
3b607e60e9
commit
fc813f67f4
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue