refactor(compiler): inline view.contentChildren
This commit is contained in:
@ -98,6 +98,9 @@ export class CompileElement extends CompileNode {
|
||||
this.view.createMethod.addStmt(statement);
|
||||
this.appElement = o.THIS_EXPR.prop(fieldName);
|
||||
this.instances.set(resolveIdentifierToken(Identifiers.AppElement).reference, this.appElement);
|
||||
if (this.hasViewContainer) {
|
||||
this.view.viewContainerAppElements.push(this.appElement);
|
||||
}
|
||||
}
|
||||
|
||||
private _createComponentFactoryResolver() {
|
||||
|
@ -32,6 +32,7 @@ export class CompileView implements NameResolver {
|
||||
public nodes: CompileNode[] = [];
|
||||
// root nodes or AppElements for ViewContainers
|
||||
public rootNodesOrAppElements: o.Expression[] = [];
|
||||
public viewContainerAppElements: o.Expression[] = [];
|
||||
|
||||
public createMethod: CompileMethod;
|
||||
public animationBindingsMethod: CompileMethod;
|
||||
|
@ -473,6 +473,8 @@ function createViewClass(
|
||||
|
||||
function generateDestroyMethod(view: CompileView): o.Statement[] {
|
||||
const stmts: o.Statement[] = [];
|
||||
view.viewContainerAppElements.forEach(
|
||||
(appElement) => { stmts.push(appElement.callMethod('destroyNestedViews', []).toStmt()); });
|
||||
view.viewChildren.forEach(
|
||||
(viewChild) => { stmts.push(viewChild.callMethod('destroy', []).toStmt()); });
|
||||
stmts.push(...view.destroyMethod.finish());
|
||||
@ -572,9 +574,11 @@ function generateDetectChangesMethod(view: CompileView): o.Statement[] {
|
||||
}
|
||||
stmts.push(...view.animationBindingsMethod.finish());
|
||||
stmts.push(...view.detectChangesInInputsMethod.finish());
|
||||
stmts.push(
|
||||
o.THIS_EXPR.callMethod('detectContentChildrenChanges', [DetectChangesVars.throwOnChange])
|
||||
.toStmt());
|
||||
view.viewContainerAppElements.forEach((appElement) => {
|
||||
stmts.push(
|
||||
appElement.callMethod('detectChangesInNestedViews', [DetectChangesVars.throwOnChange])
|
||||
.toStmt());
|
||||
});
|
||||
var afterContentStmts = view.updateContentQueriesMethod.finish().concat(
|
||||
view.afterContentLifecycleCallbacksMethod.finish());
|
||||
if (afterContentStmts.length > 0) {
|
||||
|
Reference in New Issue
Block a user