From 5f1dddc5d0a0342da2c5ef8ae3e6e5b994d2d14b Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Wed, 2 Nov 2016 07:36:31 -0700 Subject: [PATCH] refactor(compiler): cleanups --- .../compiler/src/view_compiler/lifecycle_binder.ts | 3 +-- .../compiler/src/view_compiler/property_binder.ts | 4 ++-- .../compiler/src/view_compiler/view_builder.ts | 12 +++++++----- .../@angular/core/src/linker/component_factory.ts | 4 ++-- modules/@angular/core/src/linker/view.ts | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/@angular/compiler/src/view_compiler/lifecycle_binder.ts b/modules/@angular/compiler/src/view_compiler/lifecycle_binder.ts index 0da1eb52f7..1e722529d1 100644 --- a/modules/@angular/compiler/src/view_compiler/lifecycle_binder.ts +++ b/modules/@angular/compiler/src/view_compiler/lifecycle_binder.ts @@ -61,8 +61,7 @@ export function bindDirectiveWrapperLifecycleCallbacks( DirectiveWrapperExpressions.ngOnDestroy(dir.directive, directiveWrapperIntance)); compileElement.view.detachMethod.addStmts(DirectiveWrapperExpressions.ngOnDetach( dir.hostProperties, directiveWrapperIntance, o.THIS_EXPR, - compileElement.compViewExpr ? compileElement.compViewExpr : o.THIS_EXPR, - compileElement.renderNode)); + compileElement.compViewExpr || o.THIS_EXPR, compileElement.renderNode)); } diff --git a/modules/@angular/compiler/src/view_compiler/property_binder.ts b/modules/@angular/compiler/src/view_compiler/property_binder.ts index 9cfee7d509..d241caa409 100644 --- a/modules/@angular/compiler/src/view_compiler/property_binder.ts +++ b/modules/@angular/compiler/src/view_compiler/property_binder.ts @@ -110,8 +110,8 @@ export function bindDirectiveHostProps( compileElement.view.detectChangesRenderPropertiesMethod.addStmts( DirectiveWrapperExpressions.checkHost( directiveAst.hostProperties, directiveWrapperInstance, o.THIS_EXPR, - compileElement.compViewExpr ? compileElement.compViewExpr : o.THIS_EXPR, - compileElement.renderNode, DetectChangesVars.throwOnChange, runtimeSecurityCtxExprs)); + compileElement.compViewExpr || o.THIS_EXPR, compileElement.renderNode, + DetectChangesVars.throwOnChange, runtimeSecurityCtxExprs)); } export function bindDirectiveInputs( diff --git a/modules/@angular/compiler/src/view_compiler/view_builder.ts b/modules/@angular/compiler/src/view_compiler/view_builder.ts index 139f8aa03e..772d0dce7d 100644 --- a/modules/@angular/compiler/src/view_compiler/view_builder.ts +++ b/modules/@angular/compiler/src/view_compiler/view_builder.ts @@ -246,7 +246,7 @@ class ViewBuilderVisitor implements TemplateAstVisitor { if (isPresent(compViewExpr)) { this.view.createMethod.addStmt( - compViewExpr.callMethod('create', [compileElement.getComponent(), o.NULL_EXPR]).toStmt()); + compViewExpr.callMethod('create', [compileElement.getComponent()]).toStmt()); } return null; } @@ -455,7 +455,8 @@ function createViewClass( var viewMethods = [ new o.ClassMethod( 'createInternal', [new o.FnParam(rootSelectorVar.name, o.STRING_TYPE)], - generateCreateMethod(view), o.importType(resolveIdentifier(Identifiers.ComponentRef))), + generateCreateMethod(view), + o.importType(resolveIdentifier(Identifiers.ComponentRef), [o.DYNAMIC_TYPE])), new o.ClassMethod( 'injectorGetInternal', [ @@ -562,9 +563,10 @@ function generateCreateMethod(view: CompileView): o.Statement[] { var resultExpr: o.Expression; if (view.viewType === ViewType.HOST) { const hostEl = view.nodes[0]; - resultExpr = o.importExpr(resolveIdentifier(Identifiers.ComponentRef_)).instantiate([ - o.literal(hostEl.nodeIndex), o.THIS_EXPR, hostEl.renderNode, hostEl.getComponent() - ]); + resultExpr = + o.importExpr(resolveIdentifier(Identifiers.ComponentRef_), [o.DYNAMIC_TYPE]).instantiate([ + o.literal(hostEl.nodeIndex), o.THIS_EXPR, hostEl.renderNode, hostEl.getComponent() + ]); } else { resultExpr = o.NULL_EXPR; } diff --git a/modules/@angular/core/src/linker/component_factory.ts b/modules/@angular/core/src/linker/component_factory.ts index 190ec7c4e8..9aee5e74f2 100644 --- a/modules/@angular/core/src/linker/component_factory.ts +++ b/modules/@angular/core/src/linker/component_factory.ts @@ -56,7 +56,7 @@ export abstract class ComponentRef { /** * The component type. */ - get componentType(): Type { return unimplemented(); } + get componentType(): Type { return unimplemented(); } /** * Destroys the component instance and all of the data structures associated with it. @@ -80,7 +80,7 @@ export class ComponentRef_ extends ComponentRef { get instance(): C { return this._component; }; get hostView(): ViewRef { return this._parentView.ref; }; get changeDetectorRef(): ChangeDetectorRef { return this._parentView.ref; }; - get componentType(): Type { return this._component.constructor; } + get componentType(): Type { return this._component.constructor; } destroy(): void { this._parentView.detachAndDestroy(); } onDestroy(callback: Function): void { this.hostView.onDestroy(callback); } diff --git a/modules/@angular/core/src/linker/view.ts b/modules/@angular/core/src/linker/view.ts index 28d8e35c62..87b0b06b6a 100644 --- a/modules/@angular/core/src/linker/view.ts +++ b/modules/@angular/core/src/linker/view.ts @@ -322,7 +322,7 @@ export class DebugAppView extends AppView { } } - injectorGet(token: any, nodeIndex: number, notFoundResult: any): any { + injectorGet(token: any, nodeIndex: number, notFoundResult?: any): any { this._resetDebug(); try { return super.injectorGet(token, nodeIndex, notFoundResult);