refactor(compiler): cleanups

This commit is contained in:
Tobias Bosch 2016-11-02 07:36:31 -07:00 committed by vikerman
parent 20a4f9923f
commit 5f1dddc5d0
5 changed files with 13 additions and 12 deletions

View File

@ -61,8 +61,7 @@ export function bindDirectiveWrapperLifecycleCallbacks(
DirectiveWrapperExpressions.ngOnDestroy(dir.directive, directiveWrapperIntance)); DirectiveWrapperExpressions.ngOnDestroy(dir.directive, directiveWrapperIntance));
compileElement.view.detachMethod.addStmts(DirectiveWrapperExpressions.ngOnDetach( compileElement.view.detachMethod.addStmts(DirectiveWrapperExpressions.ngOnDetach(
dir.hostProperties, directiveWrapperIntance, o.THIS_EXPR, dir.hostProperties, directiveWrapperIntance, o.THIS_EXPR,
compileElement.compViewExpr ? compileElement.compViewExpr : o.THIS_EXPR, compileElement.compViewExpr || o.THIS_EXPR, compileElement.renderNode));
compileElement.renderNode));
} }

View File

@ -110,8 +110,8 @@ export function bindDirectiveHostProps(
compileElement.view.detectChangesRenderPropertiesMethod.addStmts( compileElement.view.detectChangesRenderPropertiesMethod.addStmts(
DirectiveWrapperExpressions.checkHost( DirectiveWrapperExpressions.checkHost(
directiveAst.hostProperties, directiveWrapperInstance, o.THIS_EXPR, directiveAst.hostProperties, directiveWrapperInstance, o.THIS_EXPR,
compileElement.compViewExpr ? compileElement.compViewExpr : o.THIS_EXPR, compileElement.compViewExpr || o.THIS_EXPR, compileElement.renderNode,
compileElement.renderNode, DetectChangesVars.throwOnChange, runtimeSecurityCtxExprs)); DetectChangesVars.throwOnChange, runtimeSecurityCtxExprs));
} }
export function bindDirectiveInputs( export function bindDirectiveInputs(

View File

@ -246,7 +246,7 @@ class ViewBuilderVisitor implements TemplateAstVisitor {
if (isPresent(compViewExpr)) { if (isPresent(compViewExpr)) {
this.view.createMethod.addStmt( this.view.createMethod.addStmt(
compViewExpr.callMethod('create', [compileElement.getComponent(), o.NULL_EXPR]).toStmt()); compViewExpr.callMethod('create', [compileElement.getComponent()]).toStmt());
} }
return null; return null;
} }
@ -455,7 +455,8 @@ function createViewClass(
var viewMethods = [ var viewMethods = [
new o.ClassMethod( new o.ClassMethod(
'createInternal', [new o.FnParam(rootSelectorVar.name, o.STRING_TYPE)], '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( new o.ClassMethod(
'injectorGetInternal', 'injectorGetInternal',
[ [
@ -562,7 +563,8 @@ function generateCreateMethod(view: CompileView): o.Statement[] {
var resultExpr: o.Expression; var resultExpr: o.Expression;
if (view.viewType === ViewType.HOST) { if (view.viewType === ViewType.HOST) {
const hostEl = <CompileElement>view.nodes[0]; const hostEl = <CompileElement>view.nodes[0];
resultExpr = o.importExpr(resolveIdentifier(Identifiers.ComponentRef_)).instantiate([ resultExpr =
o.importExpr(resolveIdentifier(Identifiers.ComponentRef_), [o.DYNAMIC_TYPE]).instantiate([
o.literal(hostEl.nodeIndex), o.THIS_EXPR, hostEl.renderNode, hostEl.getComponent() o.literal(hostEl.nodeIndex), o.THIS_EXPR, hostEl.renderNode, hostEl.getComponent()
]); ]);
} else { } else {

View File

@ -56,7 +56,7 @@ export abstract class ComponentRef<C> {
/** /**
* The component type. * The component type.
*/ */
get componentType(): Type<C> { return unimplemented(); } get componentType(): Type<any> { return unimplemented(); }
/** /**
* Destroys the component instance and all of the data structures associated with it. * Destroys the component instance and all of the data structures associated with it.
@ -80,7 +80,7 @@ export class ComponentRef_<C> extends ComponentRef<C> {
get instance(): C { return this._component; }; get instance(): C { return this._component; };
get hostView(): ViewRef { return this._parentView.ref; }; get hostView(): ViewRef { return this._parentView.ref; };
get changeDetectorRef(): ChangeDetectorRef { return this._parentView.ref; }; get changeDetectorRef(): ChangeDetectorRef { return this._parentView.ref; };
get componentType(): Type<C> { return <any>this._component.constructor; } get componentType(): Type<any> { return <any>this._component.constructor; }
destroy(): void { this._parentView.detachAndDestroy(); } destroy(): void { this._parentView.detachAndDestroy(); }
onDestroy(callback: Function): void { this.hostView.onDestroy(callback); } onDestroy(callback: Function): void { this.hostView.onDestroy(callback); }

View File

@ -322,7 +322,7 @@ export class DebugAppView<T> extends AppView<T> {
} }
} }
injectorGet(token: any, nodeIndex: number, notFoundResult: any): any { injectorGet(token: any, nodeIndex: number, notFoundResult?: any): any {
this._resetDebug(); this._resetDebug();
try { try {
return super.injectorGet(token, nodeIndex, notFoundResult); return super.injectorGet(token, nodeIndex, notFoundResult);