refactor: code cleanup
This commit is contained in:
parent
9af2d8b810
commit
93d0a01d3d
|
@ -7,12 +7,10 @@
|
|||
*/
|
||||
|
||||
import {NgClass, NgFor} from '@angular/common';
|
||||
import {Component, provide} from '@angular/core';
|
||||
import {Component} from '@angular/core';
|
||||
import {ComponentFixture, TestComponentBuilder} from '@angular/core/testing';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {ListWrapper, SetWrapper, StringMapWrapper} from '../../src/facade/collection';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {ListWrapper, StringMapWrapper} from '../../src/facade/collection';
|
||||
|
||||
function detectChangesAndCheck(fixture: ComponentFixture<any>, classes: string) {
|
||||
fixture.detectChanges();
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {DirectiveResolver} from '@angular/compiler/src/directive_resolver';
|
||||
import {ContentChild, ContentChildMetadata, ContentChildren, ContentChildrenMetadata, Directive, DirectiveMetadata, HostBinding, HostListener, Input, Output, ViewChild, ViewChildMetadata, ViewChildren, ViewChildrenMetadata} from '@angular/core/src/metadata';
|
||||
import {ContentChild, ContentChildren, Directive, DirectiveMetadata, HostBinding, HostListener, Input, Output, ViewChild, ViewChildren} from '@angular/core/src/metadata';
|
||||
|
||||
@Directive({selector: 'someDirective'})
|
||||
class SomeDirective {
|
||||
|
@ -19,49 +19,47 @@ class SomeChildDirective extends SomeDirective {
|
|||
|
||||
@Directive({selector: 'someDirective', inputs: ['c']})
|
||||
class SomeDirectiveWithInputs {
|
||||
@Input() a: any /** TODO #9100 */;
|
||||
@Input('renamed') b: any /** TODO #9100 */;
|
||||
c: any /** TODO #9100 */;
|
||||
@Input() a: any;
|
||||
@Input('renamed') b: any;
|
||||
c: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', outputs: ['c']})
|
||||
class SomeDirectiveWithOutputs {
|
||||
@Output() a: any /** TODO #9100 */;
|
||||
@Output('renamed') b: any /** TODO #9100 */;
|
||||
c: any /** TODO #9100 */;
|
||||
@Output() a: any;
|
||||
@Output('renamed') b: any;
|
||||
c: any;
|
||||
}
|
||||
|
||||
|
||||
@Directive({selector: 'someDirective', outputs: ['a']})
|
||||
class SomeDirectiveWithDuplicateOutputs {
|
||||
@Output() a: any /** TODO #9100 */;
|
||||
@Output() a: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', properties: ['a']})
|
||||
class SomeDirectiveWithProperties {
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', events: ['a']})
|
||||
class SomeDirectiveWithEvents {
|
||||
@Directive({selector: 'someDirective', outputs: ['localA: a']})
|
||||
class SomeDirectiveWithDuplicateRenamedOutputs {
|
||||
@Output() a: any;
|
||||
localA: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective'})
|
||||
class SomeDirectiveWithSetterProps {
|
||||
@Input('renamed')
|
||||
set a(value: any /** TODO #9100 */) {}
|
||||
set a(value: any) {}
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective'})
|
||||
class SomeDirectiveWithGetterOutputs {
|
||||
@Output('renamed')
|
||||
get a(): any /** TODO #9100 */ { return null; }
|
||||
get a(): any { return null; }
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', host: {'[c]': 'c'}})
|
||||
class SomeDirectiveWithHostBindings {
|
||||
@HostBinding() a: any /** TODO #9100 */;
|
||||
@HostBinding('renamed') b: any /** TODO #9100 */;
|
||||
c: any /** TODO #9100 */;
|
||||
@HostBinding() a: any;
|
||||
@HostBinding('renamed') b: any;
|
||||
c: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', host: {'(c)': 'onC()'}})
|
||||
|
@ -69,31 +67,31 @@ class SomeDirectiveWithHostListeners {
|
|||
@HostListener('a')
|
||||
onA() {}
|
||||
@HostListener('b', ['$event.value'])
|
||||
onB(value: any /** TODO #9100 */) {}
|
||||
onB(value: any) {}
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', queries: {'cs': new ContentChildren('c')}})
|
||||
class SomeDirectiveWithContentChildren {
|
||||
@ContentChildren('a') as: any;
|
||||
c: any /** TODO #9100 */;
|
||||
c: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', queries: {'cs': new ViewChildren('c')}})
|
||||
class SomeDirectiveWithViewChildren {
|
||||
@ViewChildren('a') as: any;
|
||||
c: any /** TODO #9100 */;
|
||||
c: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', queries: {'c': new ContentChild('c')}})
|
||||
class SomeDirectiveWithContentChild {
|
||||
@ContentChild('a') a: any;
|
||||
c: any /** TODO #9100 */;
|
||||
c: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', queries: {'c': new ViewChild('c')}})
|
||||
class SomeDirectiveWithViewChild {
|
||||
@ViewChild('a') a: any;
|
||||
c: any /** TODO #9100 */;
|
||||
c: any;
|
||||
}
|
||||
|
||||
class SomeDirectiveWithoutMetadata {}
|
||||
|
|
|
@ -45,7 +45,7 @@ import {Router} from '../router';
|
|||
*/
|
||||
@Directive({
|
||||
selector: '[routerLink]',
|
||||
inputs: ['routeParams: routerLink', 'target: target'],
|
||||
inputs: ['routeParams: routerLink', 'target'],
|
||||
host: {
|
||||
'(click)': 'onClick()',
|
||||
'[attr.href]': 'visibleHref',
|
||||
|
|
Loading…
Reference in New Issue