fix(compiler): support string tokens with `.` inside.
This commit is contained in:
parent
386cc5dbb6
commit
cc86fee1d1
|
@ -25,7 +25,7 @@ import {
|
|||
} from 'angular2/src/core/change_detection/change_detection';
|
||||
import {ViewEncapsulation, VIEW_ENCAPSULATION_VALUES} from 'angular2/src/core/metadata/view';
|
||||
import {CssSelector} from 'angular2/src/compiler/selector';
|
||||
import {splitAtColon} from './util';
|
||||
import {splitAtColon, sanitizeIdentifier} from './util';
|
||||
import {LifecycleHooks, LIFECYCLE_HOOKS_VALUES} from 'angular2/src/core/metadata/lifecycle_hooks';
|
||||
import {getUrlScheme} from './url_resolver';
|
||||
|
||||
|
@ -318,7 +318,9 @@ export class CompileTokenMetadata implements CompileMetadataWithIdentifier {
|
|||
(isPresent(ak) && ak == token2.assetCacheKey);
|
||||
}
|
||||
|
||||
get name(): string { return isPresent(this.value) ? this.value : this.identifier.name; }
|
||||
get name(): string {
|
||||
return isPresent(this.value) ? sanitizeIdentifier(this.value) : this.identifier.name;
|
||||
}
|
||||
}
|
||||
|
||||
export class CompileTokenMap<VALUE> {
|
||||
|
|
|
@ -92,6 +92,17 @@ function declareTests(isJit: boolean) {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should support providers with string token with a `.` in it',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
var token = 'a.b';
|
||||
var tokenValue = 1;
|
||||
createInjector(tcb, [provide(token, {useValue: tokenValue})])
|
||||
.then((injector: Injector) => {
|
||||
expect(injector.get(token)).toEqual(tokenValue);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support providers with an anonymous function',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||
var token = () => true;
|
||||
|
|
Loading…
Reference in New Issue