refactor: code cleanup
This commit is contained in:
@ -7,14 +7,13 @@
|
||||
*/
|
||||
|
||||
import {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, Injectable, InputMetadata, OutputMetadata, QueryMetadata, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {ReflectorReader, reflector} from '../core_private';
|
||||
import {ListWrapper, StringMapWrapper} from '../src/facade/collection';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {Type, isPresent, stringify} from '../src/facade/lang';
|
||||
|
||||
|
||||
function _isDirectiveMetadata(type: any): boolean {
|
||||
function _isDirectiveMetadata(type: any): type is DirectiveMetadata {
|
||||
return type instanceof DirectiveMetadata;
|
||||
}
|
||||
|
||||
@ -142,5 +141,3 @@ export class DirectiveResolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export var CODEGEN_DIRECTIVE_RESOLVER = new DirectiveResolver(reflector);
|
||||
|
@ -21,12 +21,8 @@ export function camelCaseToDashCase(input: string): string {
|
||||
}
|
||||
|
||||
export function splitAtColon(input: string, defaultValues: string[]): string[] {
|
||||
var parts = StringWrapper.split(input.trim(), /\s*:\s*/g);
|
||||
if (parts.length > 1) {
|
||||
return parts;
|
||||
} else {
|
||||
return defaultValues;
|
||||
}
|
||||
var parts = input.split(':', 2).map((s: string) => s.trim());
|
||||
return parts.length > 1 ? parts : defaultValues;
|
||||
}
|
||||
|
||||
export function sanitizeIdentifier(name: string): string {
|
||||
|
@ -7,12 +7,13 @@
|
||||
*/
|
||||
|
||||
import {Injectable, ViewMetadata, ComponentMetadata,} from '@angular/core';
|
||||
|
||||
import {ReflectorReader, reflector} from '../core_private';
|
||||
|
||||
import {Type, stringify, isBlank, isPresent} from '../src/facade/lang';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {Map} from '../src/facade/collection';
|
||||
|
||||
function _isComponentMetadata(obj: any): obj is ComponentMetadata {
|
||||
return obj instanceof ComponentMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves types to {@link ViewMetadata}.
|
||||
@ -22,13 +23,8 @@ export class ViewResolver {
|
||||
constructor(private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
resolve(component: Type): ViewMetadata {
|
||||
var compMeta: ComponentMetadata;
|
||||
|
||||
this._reflector.annotations(component).forEach(m => {
|
||||
if (m instanceof ComponentMetadata) {
|
||||
compMeta = m;
|
||||
}
|
||||
});
|
||||
const compMeta: ComponentMetadata =
|
||||
this._reflector.annotations(component).find(_isComponentMetadata);
|
||||
|
||||
if (isPresent(compMeta)) {
|
||||
if (isBlank(compMeta.template) && isBlank(compMeta.templateUrl)) {
|
||||
|
Reference in New Issue
Block a user