refactor(compiler): replace CompileIdentifierMap
with regular Map
closes #11145 Also rename `CompileIdentifierMetadata.runtime` into `CompileIdentifierMetadata.reference`. Also remove `CompileIdentifierMetadata.equalsTo` as now it is enough to just check the `reference` fields for equality.
This commit is contained in:

committed by
Victor Berchet

parent
51877ef4ed
commit
d7de5c4f8e
@ -21,6 +21,6 @@ export interface PlatformReflectionCapabilities {
|
||||
setter(name: string): SetterFn;
|
||||
method(name: string): MethodFn;
|
||||
importUri(type: Type<any>): string;
|
||||
resolveType(name: string, moduleUrl: string): any;
|
||||
resolveEnum(enumType: any, name: string): any;
|
||||
resolveIdentifier(name: string, moduleUrl: string, runtime: any): any;
|
||||
resolveEnum(enumIdentifier: any, name: string): any;
|
||||
}
|
||||
|
@ -173,8 +173,8 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||
return `./${stringify(type)}`;
|
||||
}
|
||||
|
||||
resolveType(name: string, moduleUrl: string): any { return null; }
|
||||
resolveEnum(enumType: any, name: string): any { return null; }
|
||||
resolveIdentifier(name: string, moduleUrl: string, runtime: any): any { return runtime; }
|
||||
resolveEnum(enumIdentifier: any, name: string): any { return enumIdentifier[name]; }
|
||||
}
|
||||
|
||||
function convertTsickleDecoratorIntoMetadata(decoratorInvocations: any[]): any[] {
|
||||
|
@ -177,11 +177,11 @@ export class Reflector extends ReflectorReader {
|
||||
|
||||
importUri(type: any): string { return this.reflectionCapabilities.importUri(type); }
|
||||
|
||||
resolveType(name: string, moduleUrl: string): any {
|
||||
return this.reflectionCapabilities.resolveType(name, moduleUrl);
|
||||
resolveIdentifier(name: string, moduleUrl: string, runtime: any): any {
|
||||
return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, runtime);
|
||||
}
|
||||
resolveEnum(type: any, name: string): any {
|
||||
return this.reflectionCapabilities.resolveEnum(type, name);
|
||||
resolveEnum(identifier: any, name: string): any {
|
||||
return this.reflectionCapabilities.resolveEnum(identifier, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,6 @@ export abstract class ReflectorReader {
|
||||
abstract annotations(typeOrFunc: /*Type*/ any): any[];
|
||||
abstract propMetadata(typeOrFunc: /*Type*/ any): {[key: string]: any[]};
|
||||
abstract importUri(typeOrFunc: /*Type*/ any): string;
|
||||
abstract resolveType(name: string, moduleUrl: string): any;
|
||||
abstract resolveEnum(type: any, name: string): any;
|
||||
abstract resolveIdentifier(name: string, moduleUrl: string, runtime: any): any;
|
||||
abstract resolveEnum(identifier: any, name: string): any;
|
||||
}
|
||||
|
@ -149,6 +149,25 @@ function declareTests({useJit}: {useJit: boolean}) {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement).toHaveText('[]');
|
||||
});
|
||||
|
||||
it('should generate the correct output when constructors have the same name', () => {
|
||||
function ComponentFactory(selector: string, template: string) {
|
||||
@Component({selector, template})
|
||||
class MyComponent {
|
||||
}
|
||||
return MyComponent;
|
||||
}
|
||||
const HeroComponent = ComponentFactory('my-hero', 'my hero');
|
||||
const VillianComponent = ComponentFactory('a-villian', 'a villian');
|
||||
const MainComponent = ComponentFactory(
|
||||
'my-app', 'I was saved by <my-hero></my-hero> from <a-villian></a-villian>.');
|
||||
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [HeroComponent, VillianComponent, MainComponent]});
|
||||
const fixture = TestBed.createComponent(MainComponent);
|
||||
expect(fixture.debugElement.nativeElement)
|
||||
.toHaveText('I was saved by my hero from a villian.');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user