fix(ComponentUrlMapper): support relative template URLs in Dartium

When running in Dartium without using transformers (i.e. with a normal
static web server), handle relative template URLs. This works by using
mirrors to get the URL of the library where the component class is
defined.

Closes #2771

Closes #3743
This commit is contained in:
Tim Blasi
2015-08-19 16:56:46 -07:00
committed by Timothy Blasi
parent 42e1b07705
commit 7c7888de4f
8 changed files with 36 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import {Injectable} from 'angular2/di';
import {Type, isPresent} from 'angular2/src/core/facade/lang';
import {Map, MapWrapper} from 'angular2/src/core/facade/collection';
import {reflector} from 'angular2/src/core/reflection/reflection';
/**
* Resolve a `Type` from a {@link ComponentMetadata} into a URL.
@ -17,7 +18,9 @@ export class ComponentUrlMapper {
* - an absolute URL,
* - a path relative to the application
*/
getUrl(component: Type): string { return './'; }
getUrl(component: Type): string {
return reflector.isReflectionEnabled() ? reflector.importUri(component) : './';
}
}
export class RuntimeComponentUrlMapper extends ComponentUrlMapper {