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));
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));
}

View File

@ -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(

View File

@ -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 = <CompileElement>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;
}

View File

@ -56,7 +56,7 @@ export abstract class ComponentRef<C> {
/**
* 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.
@ -80,7 +80,7 @@ export class ComponentRef_<C> extends ComponentRef<C> {
get instance(): C { return this._component; };
get hostView(): ViewRef { 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(); }
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();
try {
return super.injectorGet(token, nodeIndex, notFoundResult);