refactor(core): remove DynamicComponent

BREAKING CHANGE:
A dynamic component is just a component that has no @View annotation…
This commit is contained in:
Tobias Bosch
2015-04-29 16:52:34 -07:00
parent b71fe311fc
commit 8faf6364dc
17 changed files with 76 additions and 123 deletions

View File

@ -4,7 +4,7 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection';
import {DirectiveMetadataReader} from './directive_metadata_reader';
import {Component, DynamicComponent, Decorator} from '../annotations_impl/annotations';
import {Component, Decorator} from '../annotations_impl/annotations';
import {AppProtoView} from './view';
import {ProtoViewRef} from './view_ref';
import {DirectiveBinding} from './element_injector';
@ -128,8 +128,10 @@ export class Compiler {
// It happens when a template references a component multiple times.
return pvPromise;
}
var template = this._templateResolver.resolve(component);
if (isBlank(template)) {
return null;
}
if (isPresent(template.renderer)) {
var directives = [];
pvPromise = this._renderer.createImperativeComponentProtoView(template.renderer).then( (renderPv) => {
@ -174,9 +176,7 @@ export class Compiler {
};
var nestedCall = null;
if (isPresent(nestedComponent)) {
if (!(nestedComponent.annotation instanceof DynamicComponent)) {
nestedCall = this._compile(nestedComponent);
}
nestedCall = this._compile(nestedComponent);
} else if (isPresent(nestedRenderProtoView)) {
nestedCall = this._compileNestedProtoViews(componentBinding, nestedRenderProtoView, directives, false);
}
@ -231,7 +231,7 @@ export class Compiler {
var ann = directiveBinding.annotation;
var renderType;
var compileChildren = true;
if ((ann instanceof Component) || (ann instanceof DynamicComponent)) {
if (ann instanceof Component) {
renderType = renderApi.DirectiveMetadata.COMPONENT_TYPE;
} else if (ann instanceof Decorator) {
renderType = renderApi.DirectiveMetadata.DECORATOR_TYPE;

View File

@ -4,7 +4,7 @@ import {isPresent, isBlank} from 'angular2/src/facade/lang';
import {reflector} from 'angular2/src/reflection/reflection';
import {ChangeDetection, DirectiveIndex} from 'angular2/change_detection';
import {Component, DynamicComponent} from '../annotations_impl/annotations';
import {Component} from '../annotations_impl/annotations';
import * as renderApi from 'angular2/src/render/api';
import {AppProtoView} from './view';
@ -162,7 +162,7 @@ class SortedDirectives {
this.componentDirective = null;
ListWrapper.forEach(renderDirectives, (renderDirectiveBinder) => {
var directiveBinding = allDirectives[renderDirectiveBinder.directiveIndex];
if ((directiveBinding.annotation instanceof Component) || (directiveBinding.annotation instanceof DynamicComponent)) {
if (directiveBinding.annotation instanceof Component) {
// component directives need to be the first binding in ElementInjectors!
this.componentDirective = directiveBinding;
ListWrapper.insert(this.renderDirectives, 0, renderDirectiveBinder);

View File

@ -34,7 +34,7 @@ export class TemplateResolver {
return annotation;
}
}
throw new BaseException(`No template found for ${stringify(component)}`);
// No annotation = dynamic component!
return null;
}
}