refactor(view): introduce AppViewManager to consolidate logic
AppViewManager is the single entry point to changing the view hierarchy. It is split between the manager itself which does coordination and helper methods, so both are easily testable in isolation. Also, ViewContainer is now only a pure reference to a bound element with the previous functionality but does not contain the list of views any more. Part of #1477
This commit is contained in:
13
modules/angular2/src/core/compiler/compiler.js
vendored
13
modules/angular2/src/core/compiler/compiler.js
vendored
@ -88,13 +88,17 @@ export class Compiler {
|
||||
// Create a hostView as if the compiler encountered <hostcmp></hostcmp>.
|
||||
// Used for bootstrapping.
|
||||
compileInHost(componentTypeOrBinding:any):Promise<AppProtoView> {
|
||||
var componentBinding = this._bindDirective(componentTypeOrBinding);
|
||||
this._assertTypeIsComponent(componentBinding);
|
||||
return this._renderer.createHostProtoView('host').then( (hostRenderPv) => {
|
||||
return this._compileNestedProtoViews(null, hostRenderPv, [this._bindDirective(componentTypeOrBinding)], true);
|
||||
return this._compileNestedProtoViews(null, hostRenderPv, [componentBinding], true);
|
||||
});
|
||||
}
|
||||
|
||||
compile(component: Type):Promise<AppProtoView> {
|
||||
var protoView = this._compile(this._bindDirective(component));
|
||||
var componentBinding = this._bindDirective(component);
|
||||
this._assertTypeIsComponent(componentBinding);
|
||||
var protoView = this._compile(componentBinding);
|
||||
return PromiseWrapper.isPromise(protoView) ? protoView : PromiseWrapper.resolve(protoView);
|
||||
}
|
||||
|
||||
@ -265,4 +269,9 @@ export class Compiler {
|
||||
}
|
||||
}
|
||||
|
||||
_assertTypeIsComponent(directiveBinding:DirectiveBinding):void {
|
||||
if (!(directiveBinding.annotation instanceof Component)) {
|
||||
throw new BaseException(`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user