refactor(compiler): remove obsolete @View-related code (#9019)
This commit is contained in:
committed by
Miško Hevery
parent
057abefe50
commit
52ddc96c9f
@@ -42,46 +42,18 @@ export class ViewResolver {
|
||||
/** @internal */
|
||||
_resolve(component: Type): ViewMetadata {
|
||||
var compMeta: ComponentMetadata;
|
||||
var viewMeta: ViewMetadata;
|
||||
|
||||
this._reflector.annotations(component).forEach(m => {
|
||||
if (m instanceof ViewMetadata) {
|
||||
viewMeta = m;
|
||||
}
|
||||
if (m instanceof ComponentMetadata) {
|
||||
compMeta = m;
|
||||
}
|
||||
});
|
||||
|
||||
if (isPresent(compMeta)) {
|
||||
if (isBlank(compMeta.template) && isBlank(compMeta.templateUrl) && isBlank(viewMeta)) {
|
||||
if (isBlank(compMeta.template) && isBlank(compMeta.templateUrl)) {
|
||||
throw new BaseException(
|
||||
`Component '${stringify(component)}' must have either 'template' or 'templateUrl' set.`);
|
||||
|
||||
} else if (isPresent(compMeta.template) && isPresent(viewMeta)) {
|
||||
this._throwMixingViewAndComponent("template", component);
|
||||
|
||||
} else if (isPresent(compMeta.templateUrl) && isPresent(viewMeta)) {
|
||||
this._throwMixingViewAndComponent("templateUrl", component);
|
||||
|
||||
} else if (isPresent(compMeta.directives) && isPresent(viewMeta)) {
|
||||
this._throwMixingViewAndComponent("directives", component);
|
||||
|
||||
} else if (isPresent(compMeta.pipes) && isPresent(viewMeta)) {
|
||||
this._throwMixingViewAndComponent("pipes", component);
|
||||
|
||||
} else if (isPresent(compMeta.encapsulation) && isPresent(viewMeta)) {
|
||||
this._throwMixingViewAndComponent("encapsulation", component);
|
||||
|
||||
} else if (isPresent(compMeta.styles) && isPresent(viewMeta)) {
|
||||
this._throwMixingViewAndComponent("styles", component);
|
||||
|
||||
} else if (isPresent(compMeta.styleUrls) && isPresent(viewMeta)) {
|
||||
this._throwMixingViewAndComponent("styleUrls", component);
|
||||
|
||||
} else if (isPresent(viewMeta)) {
|
||||
return viewMeta;
|
||||
|
||||
} else {
|
||||
return new ViewMetadata({
|
||||
templateUrl: compMeta.templateUrl,
|
||||
@@ -95,19 +67,9 @@ export class ViewResolver {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (isBlank(viewMeta)) {
|
||||
throw new BaseException(
|
||||
`Could not compile '${stringify(component)}' because it is not a component.`);
|
||||
} else {
|
||||
return viewMeta;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
_throwMixingViewAndComponent(propertyName: string, component: Type): void {
|
||||
throw new BaseException(
|
||||
`Component '${stringify(component)}' cannot have both '${propertyName}' and '@View' set at the same time"`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user